Jest: testNamePattern doesn't work as expected — tested again full spec name (test prefix)

Created on 4 Dec 2016  Â·  9Comments  Â·  Source: facebook/jest

Do you want to request a feature or report a bug?

bug.

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

-t '^one-package$' doesn't work because

if (config.testNamePattern) {
    const testNameRegex = new RegExp(config.testNamePattern);
    env.specFilter = spec => testNameRegex.test(spec.getFullName());
  }

Here spec.getFullName() equals to test one-package. Hard-coded prefix test is used.

Why so? Is it intended?

Related: #926

good first issue

Most helpful comment

Yes, I saw #2192 but it will be not useful for us because IntelliJ Platform is written in Kotlin/Java and in any case we have all required util/helper code.

What are your plans for IntelliJ integration?

https://youtrack.jetbrains.com/issue/WEB-14979

First phase: runner and editor gutters. To address "It would be great to support running individual tests direct from IDEA/Webstorm". Will be available in 2 weeks as part of IJ Platform 2017.1 EAP.

Second phase: test tree, test output — i.e. as any other fully supported test runner in the IJ Platform.

All 9 comments

Jasmine is using a prefix for test names. We could remove it but it would thrash all existing snapshot tests (= breaking change) so we are keeping it for now.

Hmm, I guess we could account for that in the filter. Are you willing to send a PR for that?

I am working on Jest support in the IntelliJ Platform. For me as user it is ok. For me as tool developer — not ok, because I was puzzled why my correct code doesn't work. It can leads to strange results and user confusion, because one-package$ will match foo one-package test and it is not good.

Are you willing to send a PR for that?

I hope someone will implement https://github.com/facebook/jest/issues/926#issuecomment-261241340 but in any case it should be fixed in any case.

I will try to find time to fix it. Jest is awesome and such small pitfalls should be fixed :)

Wow that is awesome to hear. Did you see https://github.com/facebook/jest/pull/2192 ? We are creating a generic editor support package that will also be used for Nuclide integration. What are your plans for IntelliJ integration? I wouldn't bet on #926 – we currently don't have any immediate plans to work on it, so I think this is something the community needs to help out with.

Yes, I saw #2192 but it will be not useful for us because IntelliJ Platform is written in Kotlin/Java and in any case we have all required util/helper code.

What are your plans for IntelliJ integration?

https://youtrack.jetbrains.com/issue/WEB-14979

First phase: runner and editor gutters. To address "It would be great to support running individual tests direct from IDEA/Webstorm". Will be available in 2 weeks as part of IJ Platform 2017.1 EAP.

Second phase: test tree, test output — i.e. as any other fully supported test runner in the IJ Platform.

Oh that sounds cool! Let me know if you need any help or input from us.

@develar are you going to send a PR for this issue?

@cpojer Sorry, not yet.

We removed the prefix in Jest 19.

Was this page helpful?
0 / 5 - 0 ratings