Jest not picking up configs in multi project mode
up vote
8
down vote
favorite
We recently migrated two different repos into a monorepo. Each uses jest with its own custom configurations, defined in their own package.json files.
I'd like to use the --projects
flag to run Jest across both projects from the root of the monorepo. I've added a jest.config.js
file to the root of the monorepo:
module.exports =
projects: ['<rootDir>/projectA', '<rootDir>/projectB']
;
The runner successfully picks up the tests for both projects, but it doesn't appear to be using each project's custom configuration. For example, in "projectA", I'm using babel-plugin-module-resolver. When I run jest in that project alone, babel-jest successfully picks up that plugin and it works fine, but when I run it from the root in multi-project mode, I get "Cannot find module..." errors that indicate the plugin isn't being used.
Similarly, in "projectB" I'm using a custom setupTestFrameworkScriptFile
. Running jest in this project runs that file just fine, but it's ignored when running from the root.
My understanding of the multi-project mode was that each individual project should keep its own settings/configs intact. Did I miss something? Do I need to configure these in the root as well?
jestjs babel-jest
add a comment |
up vote
8
down vote
favorite
We recently migrated two different repos into a monorepo. Each uses jest with its own custom configurations, defined in their own package.json files.
I'd like to use the --projects
flag to run Jest across both projects from the root of the monorepo. I've added a jest.config.js
file to the root of the monorepo:
module.exports =
projects: ['<rootDir>/projectA', '<rootDir>/projectB']
;
The runner successfully picks up the tests for both projects, but it doesn't appear to be using each project's custom configuration. For example, in "projectA", I'm using babel-plugin-module-resolver. When I run jest in that project alone, babel-jest successfully picks up that plugin and it works fine, but when I run it from the root in multi-project mode, I get "Cannot find module..." errors that indicate the plugin isn't being used.
Similarly, in "projectB" I'm using a custom setupTestFrameworkScriptFile
. Running jest in this project runs that file just fine, but it's ignored when running from the root.
My understanding of the multi-project mode was that each individual project should keep its own settings/configs intact. Did I miss something? Do I need to configure these in the root as well?
jestjs babel-jest
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10
add a comment |
up vote
8
down vote
favorite
up vote
8
down vote
favorite
We recently migrated two different repos into a monorepo. Each uses jest with its own custom configurations, defined in their own package.json files.
I'd like to use the --projects
flag to run Jest across both projects from the root of the monorepo. I've added a jest.config.js
file to the root of the monorepo:
module.exports =
projects: ['<rootDir>/projectA', '<rootDir>/projectB']
;
The runner successfully picks up the tests for both projects, but it doesn't appear to be using each project's custom configuration. For example, in "projectA", I'm using babel-plugin-module-resolver. When I run jest in that project alone, babel-jest successfully picks up that plugin and it works fine, but when I run it from the root in multi-project mode, I get "Cannot find module..." errors that indicate the plugin isn't being used.
Similarly, in "projectB" I'm using a custom setupTestFrameworkScriptFile
. Running jest in this project runs that file just fine, but it's ignored when running from the root.
My understanding of the multi-project mode was that each individual project should keep its own settings/configs intact. Did I miss something? Do I need to configure these in the root as well?
jestjs babel-jest
We recently migrated two different repos into a monorepo. Each uses jest with its own custom configurations, defined in their own package.json files.
I'd like to use the --projects
flag to run Jest across both projects from the root of the monorepo. I've added a jest.config.js
file to the root of the monorepo:
module.exports =
projects: ['<rootDir>/projectA', '<rootDir>/projectB']
;
The runner successfully picks up the tests for both projects, but it doesn't appear to be using each project's custom configuration. For example, in "projectA", I'm using babel-plugin-module-resolver. When I run jest in that project alone, babel-jest successfully picks up that plugin and it works fine, but when I run it from the root in multi-project mode, I get "Cannot find module..." errors that indicate the plugin isn't being used.
Similarly, in "projectB" I'm using a custom setupTestFrameworkScriptFile
. Running jest in this project runs that file just fine, but it's ignored when running from the root.
My understanding of the multi-project mode was that each individual project should keep its own settings/configs intact. Did I miss something? Do I need to configure these in the root as well?
jestjs babel-jest
jestjs babel-jest
edited Nov 6 '17 at 5:22
Kenrick
312213
312213
asked Oct 9 '17 at 18:32
kgoggin
649
649
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10
add a comment |
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I think there are some bugs with jest multi project runner, we need to provide some failing examples so jest can fix it. There are almost no docs about it
I made this work providing custom babel-transformer instead of using babel-jest directly.
Check this link https://twitter.com/sseraphini/status/1061779382669316098
Use this for your transformer inside packages
const config = require('../shared/babel.config.js');
const createTransformer = require('babel-jest');
module.exports = createTransformer(
...config,
);
and use this for your root transfomer
const join, resolve = require('path');
const createTransformer = require('babel-jest');
const packagePath = resolve('../');
const packageGlob = join(packagePath, '*');
module.exports = createTransformer(
babelrcRoots: packageGlob,
);
use like this on jest.config.js
transform:
'^.+\.(js,
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46652873%2fjest-not-picking-up-configs-in-multi-project-mode%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think there are some bugs with jest multi project runner, we need to provide some failing examples so jest can fix it. There are almost no docs about it
I made this work providing custom babel-transformer instead of using babel-jest directly.
Check this link https://twitter.com/sseraphini/status/1061779382669316098
Use this for your transformer inside packages
const config = require('../shared/babel.config.js');
const createTransformer = require('babel-jest');
module.exports = createTransformer(
...config,
);
and use this for your root transfomer
const join, resolve = require('path');
const createTransformer = require('babel-jest');
const packagePath = resolve('../');
const packageGlob = join(packagePath, '*');
module.exports = createTransformer(
babelrcRoots: packageGlob,
);
use like this on jest.config.js
transform:
'^.+\.(js,
add a comment |
up vote
0
down vote
I think there are some bugs with jest multi project runner, we need to provide some failing examples so jest can fix it. There are almost no docs about it
I made this work providing custom babel-transformer instead of using babel-jest directly.
Check this link https://twitter.com/sseraphini/status/1061779382669316098
Use this for your transformer inside packages
const config = require('../shared/babel.config.js');
const createTransformer = require('babel-jest');
module.exports = createTransformer(
...config,
);
and use this for your root transfomer
const join, resolve = require('path');
const createTransformer = require('babel-jest');
const packagePath = resolve('../');
const packageGlob = join(packagePath, '*');
module.exports = createTransformer(
babelrcRoots: packageGlob,
);
use like this on jest.config.js
transform:
'^.+\.(js,
add a comment |
up vote
0
down vote
up vote
0
down vote
I think there are some bugs with jest multi project runner, we need to provide some failing examples so jest can fix it. There are almost no docs about it
I made this work providing custom babel-transformer instead of using babel-jest directly.
Check this link https://twitter.com/sseraphini/status/1061779382669316098
Use this for your transformer inside packages
const config = require('../shared/babel.config.js');
const createTransformer = require('babel-jest');
module.exports = createTransformer(
...config,
);
and use this for your root transfomer
const join, resolve = require('path');
const createTransformer = require('babel-jest');
const packagePath = resolve('../');
const packageGlob = join(packagePath, '*');
module.exports = createTransformer(
babelrcRoots: packageGlob,
);
use like this on jest.config.js
transform:
'^.+\.(js,
I think there are some bugs with jest multi project runner, we need to provide some failing examples so jest can fix it. There are almost no docs about it
I made this work providing custom babel-transformer instead of using babel-jest directly.
Check this link https://twitter.com/sseraphini/status/1061779382669316098
Use this for your transformer inside packages
const config = require('../shared/babel.config.js');
const createTransformer = require('babel-jest');
module.exports = createTransformer(
...config,
);
and use this for your root transfomer
const join, resolve = require('path');
const createTransformer = require('babel-jest');
const packagePath = resolve('../');
const packageGlob = join(packagePath, '*');
module.exports = createTransformer(
babelrcRoots: packageGlob,
);
use like this on jest.config.js
transform:
'^.+\.(js,
answered Nov 12 at 13:52
Sibelius Seraphini
1,60421944
1,60421944
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46652873%2fjest-not-picking-up-configs-in-multi-project-mode%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Looking at how React does it, looks like they pointed the "projects" straight to the project's config file: github.com/facebook/react/pull/10214/…
– Kenrick
Nov 21 '17 at 4:05
React is not using projects anymore
– Sibelius Seraphini
Nov 15 at 1:10