Skip to content

Commit

Permalink
fix: support short name for Jest test environments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyr committed Nov 24, 2023
1 parent 77fe0e2 commit e5ac2f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/special/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ function filter(deps, options) {
contain(options.watchPlugins, dep, 'jest-watch-'),
);

const testEnvironment = deps.filter((dep) =>
contain(options.testEnvironment, dep, 'jest-environment-'),
);

const otherProps = lodash(options)
.entries()
.map(([prop, value]) => {
Expand All @@ -89,7 +93,9 @@ function filter(deps, options) {
.intersection(deps)
.value();

return _.uniq(runner.concat(watchPlugins).concat(otherProps));
return _.uniq(
runner.concat(watchPlugins).concat(testEnvironment).concat(otherProps),
);
}

function checkOptions(deps, options = {}) {
Expand Down
10 changes: 10 additions & 0 deletions test/special/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ const testCases = [
deps: ['jest-watch-master', 'jest-watch-select-projects'],
content: { watchPlugins: ['master', 'select-projects'] },
},
{
name: 'recognize single short-name test environment',
deps: ['jest-environment-jsdom'],
content: { testEnvironment: 'jsdom' },
},
{
name: 'recognize single long-name test environment',
deps: ['jest-environment-jsdom'],
content: { testEnvironment: 'jest-environment-jsdom' },
},
{
name: 'recognize module with options',
deps: ['jest-watch-master'],
Expand Down

0 comments on commit e5ac2f3

Please sign in to comment.