Skip to content

Commit

Permalink
fix(testing): fix jest paths for root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Nov 30, 2022
1 parent f16f53b commit dc880a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
40 changes: 35 additions & 5 deletions packages/jest/src/utils/config/get-jest-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ describe('getJestProjects', () => {
jest
.spyOn(Workspace, 'readWorkspaceConfig')
.mockImplementation(() => mockedWorkspaceConfig);
const expectedResults = ['<rootDir>/test/jest/config/location'];
const expectedResults = [
'<rootDir>/test/jest/config/location/jest.config.js',
];
expect(getJestProjects()).toEqual(expectedResults);
});

Expand All @@ -47,7 +49,33 @@ describe('getJestProjects', () => {
jest
.spyOn(Workspace, 'readWorkspaceConfig')
.mockImplementation(() => mockedWorkspaceConfig);
const expectedResults = ['<rootDir>/test/jest/config/location'];
const expectedResults = [
'<rootDir>/test/jest/config/location/jest.config.js',
];
expect(getJestProjects()).toEqual(expectedResults);
});

test('root project', () => {
const mockedWorkspaceConfig: WorkspaceJsonConfiguration = {
projects: {
'test-1': {
root: '.',
targets: {
test: {
executor: '@nrwl/jest:jest',
options: {
jestConfig: 'jest.config.app.js',
},
},
},
},
},
version: 1,
};
jest
.spyOn(Workspace, 'readWorkspaceConfig')
.mockImplementation(() => mockedWorkspaceConfig);
const expectedResults = ['<rootDir>/jest.config.app.js'];
expect(getJestProjects()).toEqual(expectedResults);
});

Expand Down Expand Up @@ -77,8 +105,8 @@ describe('getJestProjects', () => {
.spyOn(Workspace, 'readWorkspaceConfig')
.mockImplementation(() => mockedWorkspaceConfig);
const expectedResults = [
'<rootDir>/test/jest/config/location',
'<rootDir>/configuration-specific',
'<rootDir>/test/jest/config/location/jest.config.js',
'<rootDir>/configuration-specific/jest.config.js',
];
expect(getJestProjects()).toEqual(expectedResults);
});
Expand Down Expand Up @@ -108,7 +136,9 @@ describe('getJestProjects', () => {
jest
.spyOn(Workspace, 'readWorkspaceConfig')
.mockImplementation(() => mockedWorkspaceConfig);
const expectedResults = ['<rootDir>/test/jest/config/location'];
const expectedResults = [
'<rootDir>/test/jest/config/location/jest.config.js',
];
expect(getJestProjects()).toEqual(expectedResults);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/jest/src/utils/config/get-jest-projects.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dirname, join } from 'path';
import { join } from 'path';
import type { ProjectsConfigurations } from '@nrwl/devkit';
import { readWorkspaceConfig } from 'nx/src/project-graph/file-utils';

const JEST_RUNNER_TOKEN = '@nrwl/jest:jest';

function getJestConfigProjectPath(projectJestConfigPath: string): string {
return join('<rootDir>', dirname(projectJestConfigPath));
return join('<rootDir>', projectJestConfigPath);
}

export function getJestProjects() {
Expand Down

0 comments on commit dc880a9

Please sign in to comment.