Skip to content

Commit 4ed3b42

Browse files
committed
fix tests
1 parent 2255b8e commit 4ed3b42

File tree

12 files changed

+42
-16
lines changed

12 files changed

+42
-16
lines changed

angular.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"options": {
7979
"jestConfig": "apps/example-app/jest.config.js",
8080
"tsConfig": "apps/example-app/tsconfig.spec.json",
81-
"setupFile": "apps/example-app/setup-jest.ts"
81+
"setupFile": "apps/example-app/test-setup.ts"
8282
}
8383
}
8484
}
@@ -134,7 +134,7 @@
134134
"options": {
135135
"jestConfig": "projects/testing-library/jest.config.js",
136136
"tsConfig": "projects/testing-library/tsconfig.spec.json",
137-
"setupFile": "projects/testing-library/setup-jest.ts"
137+
"setupFile": "projects/testing-library/test-setup.ts"
138138
}
139139
}
140140
}
@@ -181,7 +181,7 @@
181181
"options": {
182182
"jestConfig": "projects/jest-utils/jest.config.js",
183183
"tsConfig": "projects/jest-utils/tsconfig.spec.json",
184-
"setupFile": "projects/jest-utils/setup-jest.ts"
184+
"setupFile": "projects/jest-utils/test-setup.ts"
185185
}
186186
}
187187
}

apps/example-app/setup-jest.ts renamed to apps/example-app/test-setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import '@testing-library/jest-dom';
33
import { configure } from '@testing-library/angular';
44
import { ReactiveFormsModule } from '@angular/forms';
55

6+
Object.defineProperty(document.body.style, 'transform', {
7+
value: () => {
8+
return {
9+
enumerable: true,
10+
configurable: true,
11+
};
12+
},
13+
});
14+
615
configure({
716
defaultImports: [ReactiveFormsModule],
817
});

apps/example-app/tsconfig.spec.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"module": "commonjs",
5-
"types": ["jest", "node"]
6-
}
5+
"types": ["node", "jest"]
6+
},
7+
"files": ["test-setup.ts"],
8+
"include": ["**/*.spec.ts", "**/*.d.ts"]
79
}

jest.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@ module.exports = {
66
resolver: '@nrwl/jest/plugins/resolver',
77
moduleFileExtensions: ['ts', 'js', 'html'],
88
coverageReporters: ['html'],
9+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
910
snapshotSerializers: [
1011
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
1112
'jest-preset-angular/build/AngularSnapshotSerializer.js',
1213
'jest-preset-angular/build/HTMLCommentSerializer.js',
1314
],
15+
globals: {
16+
'ts-jest': {
17+
tsConfig: '<rootDir>/tsconfig.spec.json',
18+
stringifyContentPathRegex: '\\.(html|svg)$',
19+
astTransformers: [
20+
'jest-preset-angular/build/InlineFilesTransformer',
21+
'jest-preset-angular/build/StripStylesTransformer',
22+
],
23+
},
24+
},
1425
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "nx run-many --target=build --all",
8-
"test": "yarn affected:test",
8+
"test": "nx run-many --target=test --all",
99
"lint": "nx workspace-lint && ng lint",
1010
"e2e": "ng e2e",
1111
"affected:apps": "nx affected:apps",
@@ -34,7 +34,7 @@
3434
"@nrwl/angular": "^10.0.0",
3535
"@nrwl/nx-cloud": "^10.0.0",
3636
"@phenomnomnominal/tsquery": "^4.1.0",
37-
"@testing-library/dom": "^7.18.1",
37+
"@testing-library/dom": "^7.24.1",
3838
"@testing-library/user-event": "^12.0.11",
3939
"core-js": "^3.6.5",
4040
"rxjs": "^6.5.5",
File renamed without changes.

projects/jest-utils/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"experimentalDecorators": true,
1313
"importHelpers": true,
1414
"allowSyntheticDefaultImports": true,
15-
"types": ["@types/jest"],
15+
"types": ["jest"],
1616
"lib": ["dom", "es2015"]
1717
},
1818
"angularCompilerOptions": {

projects/jest-utils/tsconfig.spec.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"module": "commonjs",
5-
"types": ["jest", "node"]
6-
}
5+
"types": ["node", "jest"]
6+
},
7+
"files": ["test-setup.ts"],
8+
"include": ["**/*.spec.ts", "**/*.d.ts"]
79
}

projects/testing-library/tests/migration/4_0_0.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('Migration to version 4.0.0', () => {
8383
async function setup() {
8484
await render(
8585
HomeComponent,
86-
86+
8787
{componentProperties: {
8888
value: 'foo',
8989
count: 2
@@ -107,12 +107,12 @@ describe('Migration to version 4.0.0', () => {
107107
process.chdir(getSystemPath(host.root));
108108
await host.write(specPath, input).toPromise();
109109

110-
schematicRunner.runSchematic('migration-4.0.0', {}, tree);
110+
await schematicRunner.runSchematicAsync('migration-4.0.0', {}, tree).toPromise();
111111
await schematicRunner.engine.executePostTasks().toPromise();
112112

113113
const actual = await host.read(specPath).toPromise().then(virtualFs.fileBufferToString);
114114

115-
expect(actual).toBe(expected);
115+
expect(actual.replace(/\s/g, '')).toBe(expected.replace(/\s/g, ''));
116116
});
117117
});
118118
});

projects/testing-library/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"emitDecoratorMetadata": true,
1212
"experimentalDecorators": true,
1313
"importHelpers": false,
14-
"types": ["@types/jest", "@types/node"],
14+
"types": ["node", "jest"],
1515
"lib": ["dom", "es2015", "es2018.promise"]
1616
},
1717
"angularCompilerOptions": {

projects/testing-library/tsconfig.spec.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"module": "commonjs",
5-
"types": ["jest", "node"]
6-
}
5+
"types": ["node", "jest"]
6+
},
7+
"files": ["test-setup.ts"],
8+
"include": ["**/*.spec.ts", "**/*.d.ts"]
79
}

0 commit comments

Comments
 (0)