Skip to content

Commit

Permalink
fix(testing): update tests for jest.config.ts changes
Browse files Browse the repository at this point in the history
update tests broken by renaming jest fils to ts files
  • Loading branch information
barbados-clemens committed Apr 21, 2022
1 parent 156505d commit fb40831
Show file tree
Hide file tree
Showing 42 changed files with 294 additions and 181 deletions.
2 changes: 1 addition & 1 deletion e2e/angular-core/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const angularV1Json = (appName: string) => `{
"builder": "@nrwl/jest:jest",
"outputs": ["coverage/apps/${appName}"],
"options": {
"jestConfig": "apps/${appName}/jest.config.js",
"jestConfig": "apps/${appName}/jest.config.ts",
"passWithNoTests": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Jest', () => {
);

updateFile(
`libs/${mylib}/jest.config.js`,
`libs/${mylib}/jest.config.ts`,
stripIndents`
module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
Expand Down
4 changes: 2 additions & 2 deletions e2e/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ describe('nest libraries', function () {
const nestlib = uniq('nestlib');
runCLI(`generate @nrwl/nest:lib ${nestlib}`);

const jestConfigContent = readFile(`libs/${nestlib}/jest.config.js`);
const jestConfigContent = readFile(`libs/${nestlib}/jest.config.ts`);

expect(stripIndents`${jestConfigContent}`).toEqual(
stripIndents`module.exports = {
displayName: '${nestlib}',
preset: '../../jest.preset.js',
preset: '../../jest.preset.ts',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ export function expectNoAngularDevkit() {

export function expectNoTsJestInJestConfig(appName: string) {
const jestConfig = readFile(
joinPathFragments('apps', appName, 'jest.config.js')
joinPathFragments('apps', appName, 'jest.config.ts')
);
expect(jestConfig).not.toContain('ts-jest');
}
Expand Down
14 changes: 7 additions & 7 deletions e2e/workspace-core/src/aux-commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('workspace-lint', () => {
expect(stdout).toContain(
'The following file(s) do not belong to any projects:'
);
expect(stdout).toContain(`- apps/${appAfter}/jest.config.js`);
expect(stdout).toContain(`- apps/${appAfter}/jest.config.ts`);
expect(stdout).toContain(`- apps/${appAfter}/src/app/app.component.css`);
expect(stdout).toContain(`- apps/${appAfter}/src/app/app.component.html`);
expect(stdout).toContain(
Expand Down Expand Up @@ -257,12 +257,12 @@ describe('move project', () => {
expect(moveOutput).toContain(`CREATE ${readmePath}`);
checkFilesExist(readmePath);

const jestConfigPath = `${newPath}/jest.config.js`;
const jestConfigPath = `${newPath}/jest.config.ts`;
expect(moveOutput).toContain(`CREATE ${jestConfigPath}`);
checkFilesExist(jestConfigPath);
const jestConfig = readFile(jestConfigPath);
expect(jestConfig).toContain(`displayName: 'shared-${lib1}-data-access'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.js'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.ts'`);
expect(jestConfig).toContain(`'../../../../coverage/${newPath}'`);

const tsConfigPath = `${newPath}/tsconfig.json`;
Expand Down Expand Up @@ -395,12 +395,12 @@ describe('move project', () => {
expect(moveOutput).toContain(`CREATE ${readmePath}`);
checkFilesExist(readmePath);

const jestConfigPath = `${newPath}/jest.config.js`;
const jestConfigPath = `${newPath}/jest.config.ts`;
expect(moveOutput).toContain(`CREATE ${jestConfigPath}`);
checkFilesExist(jestConfigPath);
const jestConfig = readFile(jestConfigPath);
expect(jestConfig).toContain(`displayName: 'shared-${lib1}-data-access'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.js'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.ts'`);
expect(jestConfig).toContain(`'../../../../coverage/${newPath}'`);

const tsConfigPath = `${newPath}/tsconfig.json`;
Expand Down Expand Up @@ -528,12 +528,12 @@ describe('move project', () => {
expect(moveOutput).toContain(`CREATE ${readmePath}`);
checkFilesExist(readmePath);

const jestConfigPath = `${newPath}/jest.config.js`;
const jestConfigPath = `${newPath}/jest.config.ts`;
expect(moveOutput).toContain(`CREATE ${jestConfigPath}`);
checkFilesExist(jestConfigPath);
const jestConfig = readFile(jestConfigPath);
expect(jestConfig).toContain(`displayName: 'shared-${lib1}-data-access'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.js'`);
expect(jestConfig).toContain(`preset: '../../../../jest.preset.ts'`);
expect(jestConfig).toContain(`'../../../../coverage/${newPath}'`);

const tsConfigPath = `${newPath}/tsconfig.json`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ describe('Move Angular Project', () => {
// just check the output
expect(moveOutput).toContain(`DELETE apps/${app1}`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/.browserslistrc`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/jest.config.js`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/jest.config.ts`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/tsconfig.app.json`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/tsconfig.json`);
expect(moveOutput).toContain(`CREATE apps/${newPath}/tsconfig.spec.json`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Object {
"test": Object {
"builder": "@nrwl/jest:jest",
"options": Object {
"jestConfig": "apps/my-dir/my-app/jest.config.js",
"jestConfig": "apps/my-dir/my-app/jest.config.ts",
"passWithNoTests": true,
},
"outputs": Array [
Expand Down Expand Up @@ -281,7 +281,7 @@ Object {
"test": Object {
"builder": "@nrwl/jest:jest",
"options": Object {
"jestConfig": "apps/my-app/jest.config.js",
"jestConfig": "apps/my-app/jest.config.ts",
"passWithNoTests": true,
},
"outputs": Array [
Expand Down
18 changes: 9 additions & 9 deletions packages/angular/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('app', () => {
it('should generate files', async () => {
await generateApp(appTree);

expect(appTree.exists(`apps/my-app/jest.config.js`)).toBeTruthy();
expect(appTree.exists(`apps/my-app/jest.config.ts`)).toBeTruthy();
expect(appTree.exists('apps/my-app/src/main.ts')).toBeTruthy();
expect(appTree.exists('apps/my-app/src/app/app.module.ts')).toBeTruthy();
expect(
Expand Down Expand Up @@ -113,13 +113,13 @@ describe('app', () => {
it('should setup jest with serializers', async () => {
await generateApp(appTree);

expect(appTree.read('apps/my-app/jest.config.js', 'utf-8')).toContain(
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
`'jest-preset-angular/build/serializers/no-ng-attributes'`
);
expect(appTree.read('apps/my-app/jest.config.js', 'utf-8')).toContain(
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
`'jest-preset-angular/build/serializers/ng-snapshot'`
);
expect(appTree.read('apps/my-app/jest.config.js', 'utf-8')).toContain(
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
`'jest-preset-angular/build/serializers/html-comment'`
);
});
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('app', () => {

// Make sure these exist
[
`apps/my-dir/my-app/jest.config.js`,
`apps/my-dir/my-app/jest.config.ts`,
'apps/my-dir/my-app/src/main.ts',
'apps/my-dir/my-app/src/app/app.module.ts',
'apps/my-dir/my-app/src/app/app.component.ts',
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('app', () => {

// Make sure these exist
[
'my-dir/my-app/jest.config.js',
'my-dir/my-app/jest.config.ts',
'my-dir/my-app/src/main.ts',
'my-dir/my-app/src/app/app.module.ts',
'my-dir/my-app/src/app/app.component.ts',
Expand Down Expand Up @@ -631,10 +631,10 @@ describe('app', () => {

describe('--unit-test-runner', () => {
describe('default (jest)', () => {
it('should generate jest.config.js with serializers', async () => {
it('should generate jest.config.ts with serializers', async () => {
await generateApp(appTree);

const jestConfig = appTree.read('apps/my-app/jest.config.js', 'utf-8');
const jestConfig = appTree.read('apps/my-app/jest.config.ts', 'utf-8');

expect(jestConfig).toContain(
`'jest-preset-angular/build/serializers/no-ng-attributes'`
Expand Down Expand Up @@ -678,7 +678,7 @@ describe('app', () => {
expect(appTree.exists('apps/my-app/src/test-setup.ts')).toBeFalsy();
expect(appTree.exists('apps/my-app/src/test.ts')).toBeFalsy();
expect(appTree.exists('apps/my-app/tsconfig.spec.json')).toBeFalsy();
expect(appTree.exists('apps/my-app/jest.config.js')).toBeFalsy();
expect(appTree.exists('apps/my-app/jest.config.ts')).toBeFalsy();
expect(appTree.exists('apps/my-app/karma.config.js')).toBeFalsy();
expect(
appTree.exists('apps/my-app/src/app/app.component.spec.ts')
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('init', () => {
skipFormat: false,
});

const hasJestConfigFile = host.exists('jest.config.js');
const hasJestConfigFile = host.exists('jest.config.ts');

// ASSERT
expect(hasJestConfigFile).toBeTruthy();
Expand Down
12 changes: 6 additions & 6 deletions packages/angular/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ describe('lib', () => {
await runLibraryGeneratorWithOpts({ name: 'my-lib2' });

// ASSERT
expect(tree.exists(`libs/my-lib/jest.config.js`)).toBeTruthy();
expect(tree.exists(`libs/my-lib/jest.config.ts`)).toBeTruthy();
expect(tree.exists('libs/my-lib/src/index.ts')).toBeTruthy();
expect(tree.exists('libs/my-lib/src/lib/my-lib.module.ts')).toBeTruthy();

Expand All @@ -444,7 +444,7 @@ describe('lib', () => {
tree.exists('libs/my-lib/src/lib/my-lib.service.spec.ts')
).toBeFalsy();

expect(tree.exists(`libs/my-lib2/jest.config.js`)).toBeTruthy();
expect(tree.exists(`libs/my-lib2/jest.config.ts`)).toBeTruthy();
expect(tree.exists('libs/my-lib2/src/index.ts')).toBeTruthy();
expect(
tree.exists('libs/my-lib2/src/lib/my-lib2.module.ts')
Expand Down Expand Up @@ -544,7 +544,7 @@ describe('lib', () => {
});

// ASSERT
expect(tree.exists(`libs/my-dir/my-lib/jest.config.js`)).toBeTruthy();
expect(tree.exists(`libs/my-dir/my-lib/jest.config.ts`)).toBeTruthy();
expect(tree.exists('libs/my-dir/my-lib/src/index.ts')).toBeTruthy();
expect(
tree.exists('libs/my-dir/my-lib/src/lib/my-dir-my-lib.module.ts')
Expand All @@ -563,7 +563,7 @@ describe('lib', () => {
tree.exists('libs/my-dir/my-lib/src/lib/my-lib.service.spec.ts')
).toBeFalsy();

expect(tree.exists(`libs/my-dir/my-lib2/jest.config.js`)).toBeTruthy();
expect(tree.exists(`libs/my-dir/my-lib2/jest.config.ts`)).toBeTruthy();
expect(tree.exists('libs/my-dir/my-lib2/src/index.ts')).toBeTruthy();
expect(
tree.exists('libs/my-dir/my-lib2/src/lib/my-lib2.module.ts')
Expand Down Expand Up @@ -740,7 +740,7 @@ describe('lib', () => {
// Make sure these exist
[
'my-dir/my-lib/.browserslistrc',
'my-dir/my-lib/jest.config.js',
'my-dir/my-lib/jest.config.ts',
'my-dir/my-lib/ng-package.json',
'my-dir/my-lib/project.json',
'my-dir/my-lib/tsconfig.lib.prod.json',
Expand Down Expand Up @@ -1192,7 +1192,7 @@ describe('lib', () => {
expect(tree.exists('libs/my-lib/src/test.ts')).toBeFalsy();
expect(tree.exists('libs/my-lib/src/test.ts')).toBeFalsy();
expect(tree.exists('libs/my-lib/tsconfig.spec.json')).toBeFalsy();
expect(tree.exists('libs/my-lib/jest.config.js')).toBeFalsy();
expect(tree.exists('libs/my-lib/jest.config.ts')).toBeFalsy();
expect(tree.exists('libs/my-lib/karma.conf.js')).toBeFalsy();
expect(workspaceJson.projects['my-lib'].architect.test).toBeUndefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ Array [
"apps/one/two/test-ui-lib-e2e/src/support/commands.ts",
"apps/one/two/test-ui-lib-e2e/src/support/index.ts",
"apps/one/two/test-ui-lib-e2e/tsconfig.json",
"jest.config.js",
"jest.preset.js",
"jest.config.ts",
"jest.preset.ts",
"libs/test-ui-lib/.eslintrc.json",
"libs/test-ui-lib/.storybook/main.js",
"libs/test-ui-lib/.storybook/preview.js",
"libs/test-ui-lib/.storybook/tsconfig.json",
"libs/test-ui-lib/jest.config.js",
"libs/test-ui-lib/jest.config.ts",
"libs/test-ui-lib/README.md",
"libs/test-ui-lib/src/index.ts",
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
Expand Down Expand Up @@ -159,13 +159,13 @@ Array [
"apps/test-ui-lib-e2e/src/support/commands.ts",
"apps/test-ui-lib-e2e/src/support/index.ts",
"apps/test-ui-lib-e2e/tsconfig.json",
"jest.config.js",
"jest.preset.js",
"jest.config.ts",
"jest.preset.ts",
"libs/test-ui-lib/.eslintrc.json",
"libs/test-ui-lib/.storybook/main.js",
"libs/test-ui-lib/.storybook/preview.js",
"libs/test-ui-lib/.storybook/tsconfig.json",
"libs/test-ui-lib/jest.config.js",
"libs/test-ui-lib/jest.config.ts",
"libs/test-ui-lib/README.md",
"libs/test-ui-lib/src/index.ts",
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Object {
],
},
"exclude": Array [
"jest.config.ts",
"**/*.spec.ts",
"**/*.test.ts",
],
Expand Down Expand Up @@ -124,6 +125,7 @@ Object {
);
expect(tsConfigApp.include).toEqual(['**/*.ts', '**/*.js']);
expect(tsConfigApp.exclude).toEqual([
'jest.config.ts',
'**/*.spec.ts',
'**/*.test.ts',
'**/*.spec.js',
Expand Down

0 comments on commit fb40831

Please sign in to comment.