Skip to content

Commit

Permalink
Read runtime in jest plugin (closes #603)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 3, 2024
1 parent db3fe40 commit d766006
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/knip/fixtures/plugins/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module.exports = {
...require('./jest.config.shared'),
displayName: 'dev',
runtime: '@side/jest-runtime',
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
setupFiles: [],
moduleNameMapper: {
Expand Down
2 changes: 2 additions & 0 deletions packages/knip/src/plugins/jest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const resolveDependencies = async (config: JestInitialOptions, options: PluginOp
}

const runner = config.runner ? [config.runner] : [];
const runtime = config.runtime && config.runtime !== 'jest-circus' ? [config.runtime] : [];
const environments = config.testEnvironment === 'jsdom' ? ['jest-environment-jsdom'] : [];
const resolvers = config.resolver ? [config.resolver] : [];
const reporters = config.reporters
Expand Down Expand Up @@ -90,6 +91,7 @@ const resolveDependencies = async (config: JestInitialOptions, options: PluginOp
...presets,
...projects,
...runner,
...runtime,
...environments,
...resolvers,
...reporters,
Expand Down
3 changes: 2 additions & 1 deletion packages/knip/test/plugins/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test('Find dependencies with the Jest plugin', async () => {
assert(issues.unlisted['jest.config.shared.js']['@jest/types']);
assert(issues.unlisted['jest.setup.js']['@testing-library/jest-dom']);
assert(issues.unlisted['jest.config.js']['@jest/types']);
assert(issues.unresolved['jest.config.js']['@side/jest-runtime']);
assert(issues.unresolved['jest.config.js']['@nrwl/react/plugins/jest']);
assert(issues.unresolved['jest.config.js']['babel-jest']);
assert(issues.unresolved['jest.config.js']['identity-obj-proxy']);
Expand All @@ -29,7 +30,7 @@ test('Find dependencies with the Jest plugin', async () => {
...baseCounters,
devDependencies: 1,
unlisted: 3,
unresolved: 8,
unresolved: 9,
processed: 6,
total: 6,
});
Expand Down

0 comments on commit d766006

Please sign in to comment.