Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export function pathToJestPackageJSON(pluginSettings: IPluginSettings): string |
}

const defaultPath = normalize(join(pathToNodeModules, 'jest/package.json'))
const cliPath = normalize(join(pathToNodeModules, 'jest-cli/package.json'))
const craPath = normalize(join(pathToNodeModules, 'react-scripts/node_modules/jest/package.json'))
const paths = [defaultPath, craPath]
const paths = [defaultPath, cliPath, craPath]

for (const i in paths) {
if (existsSync(paths[i])) {
Expand Down
11 changes: 11 additions & 0 deletions tests/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('ModuleHelpers', () => {
expect(pathToJestPackageJSON(workspace)).toBe(expected)
})

it('should return package.json when Jest-cli is installed as a dependency', () => {
const expected = path.join('..', '..', 'node_modules', 'jest-cli', 'package.json')
existsMock.mockImplementation(path => path === expected)

const workspace: any = {
rootPath: path.join('..', '..'),
pathToJest: defaultPathToJest,
}
expect(pathToJestPackageJSON(workspace)).toBe(expected)
})

it('should return package.json when React Scripts are installed as a dependency', () => {
const expected = path.join(
'..',
Expand Down