Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two projects with different modulePaths have failing tests #4649

Closed
gziolo opened this issue Oct 10, 2017 · 4 comments
Closed

Two projects with different modulePaths have failing tests #4649

gziolo opened this issue Oct 10, 2017 · 4 comments

Comments

@gziolo
Copy link
Contributor

gziolo commented Oct 10, 2017

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

Bug.

What is the current behavior?

I have opened a PR to better illustrate the issue:

Automattic/wp-calypso#18702

We are using:

  • node 6.11.2
  • npm 3.10.10
  • jest 21.2.0

I wanted to combine two Jest project into one mirroring one of the PRs from the React's repository: facebook/react#10214 to be able to use one command npm test aliasing jest. At the moment we have to run two projects independently which isn't the best developer's experience in my opinion. Both of them pass when executed in isolation.

At the moment a few tests fail when I run npm test:

Summary of all failing tests
FAIL server/pages/test/analytics.js
Test suite failed to run

Cannot find module 'pages/analytics' from 'analytics.js'
  
  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
  at Object.<anonymous> (server/pages/test/analytics.js:15:19)

FAIL server/config/test/parser.js
parser › should return empty objects for an invalid path

Cannot find module 'config/parser' from 'parser.js'
  
  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
  at Object.<anonymous> (server/config/test/parser.js:8:12)

parser › server should have secrets and client should not

TypeError: require(...).__setValidSecrets is not a function
  
  at Object.<anonymous> (server/config/test/parser.js:16:17)
  at process._tickCallback (internal/process/next_tick.js:109:7)

parser › should cascade configs

TypeError: require(...).__setValidEnvFiles is not a function
  
  at Object.<anonymous> (server/config/test/parser.js:26:17)
  at process._tickCallback (internal/process/next_tick.js:109:7)

parser › should override enabled feature when disabledFeatures set

TypeError: require(...).__setValidEnvFiles is not a function
  
  at Object.<anonymous> (server/config/test/parser.js:47:17)
  at process._tickCallback (internal/process/next_tick.js:109:7)

parser › should override disabled feature when enabledFeatures set

TypeError: require(...).__setValidEnvFiles is not a function
  
  at Object.<anonymous> (server/config/test/parser.js:59:17)
  at process._tickCallback (internal/process/next_tick.js:109:7)

Test Suites: 2 failed, 1023 passed, 1025 total
Tests: 5 failed, 8 skipped, 9491 passed, 9504 total
Snapshots: 2 passed, 2 total
Time: 65.965s
Ran all test suites in 2 projects.

If you run only subset of tests using the following command npm run test server, then all the failing tests pass:

Test Suites: 6 passed, 6 total
Tests: 29 passed, 29 total
Snapshots: 0 total
Time: 2.434s
Ran all test suites matching /server/i in 2 projects.

We use different setup for both projects and my bet is that the module paths is the source of this error as they differ in those two config files:

"modulePaths": [
	"<rootDir>/test/",
	"<rootDir>/client/",
	"<rootDir>/client/extensions/"
],

full config file

vs

"modulePaths": [
	"<rootDir>/test/",
	"<rootDir>/server/",
	"<rootDir>/client/",
	"<rootDir>/client/extensions/"
],

full config file

What is the expected behavior?

It's possible to execute npm test which is alias to jest with the following config in package.json:

"jest": {
     "projects": [
       "test/client/jest.config.json",
       "test/server/jest.config.json"
     ]
},

and all tests pass.

@thymikee
Copy link
Collaborator

cc @aaronabramov

@gziolo
Copy link
Contributor Author

gziolo commented Oct 19, 2017

It seems to be related to #4649 if I read the comment properly:

this is actually expected (although not perfect) right now due to some of our design decisions.

since coverage is reported from the master process, it can't be configured per project.
another thing that we have is that if you don't provide a globalConfig option, global config values will be taken from the first project you pass (client in your case).

there isn't really much we can do right now without changing most of the multi-project runner design, and honestly i haven't tested coverage generating with MPR yet, i'm pretty sure we have a lot of bugs there :(

@gziolo gziolo closed this as completed Feb 8, 2019
@SimenB
Copy link
Member

SimenB commented Feb 8, 2019

since coverage is reported from the master process, it can't be configured per project.
another thing that we have is that if you don't provide a globalConfig option, global config values will be taken from the first project you pass (client in your case).

We might wanna address that in #7185

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants