@o3r/testing 14.2.0-prerelease.0 → 14.2.0-prerelease.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/schematics/ng-add/jest/index.d.ts +6 -1
- package/schematics/ng-add/jest/index.d.ts.map +1 -1
- package/schematics/ng-add/jest/index.js +37 -7
- package/schematics/ng-add/jest/index.js.map +1 -1
- package/schematics/ng-add/jest/templates/workspace/jest.config.js.template +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "14.2.0-prerelease.
|
|
3
|
+
"version": "14.2.0-prerelease.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"@material/slider": "^14.0.0",
|
|
100
100
|
"@ngrx/store": "^21.0.0",
|
|
101
101
|
"@ngx-translate/core": "^15.0.0 || ~16.0.4",
|
|
102
|
-
"@o3r/core": "~14.2.0-prerelease.
|
|
103
|
-
"@o3r/eslint-config": "~14.2.0-prerelease.
|
|
104
|
-
"@o3r/localization": "~14.2.0-prerelease.
|
|
105
|
-
"@o3r/schematics": "~14.2.0-prerelease.
|
|
102
|
+
"@o3r/core": "~14.2.0-prerelease.2",
|
|
103
|
+
"@o3r/eslint-config": "~14.2.0-prerelease.2",
|
|
104
|
+
"@o3r/localization": "~14.2.0-prerelease.2",
|
|
105
|
+
"@o3r/schematics": "~14.2.0-prerelease.2",
|
|
106
106
|
"@playwright/test": "^1.49.0",
|
|
107
107
|
"@schematics/angular": "^21.0.0",
|
|
108
108
|
"eslint": "~9.39.0",
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
"dependencies": {
|
|
173
|
-
"@o3r/schematics": "~14.2.0-prerelease.
|
|
173
|
+
"@o3r/schematics": "~14.2.0-prerelease.2",
|
|
174
174
|
"esbuild": "~0.27.0",
|
|
175
175
|
"tslib": "^2.6.2"
|
|
176
176
|
},
|
|
@@ -196,11 +196,11 @@
|
|
|
196
196
|
"@ngx-translate/core": "~16.0.4",
|
|
197
197
|
"@nx/eslint-plugin": "~22.5.3",
|
|
198
198
|
"@nx/jest": "~22.5.3",
|
|
199
|
-
"@o3r/build-helpers": "~14.2.0-prerelease.
|
|
200
|
-
"@o3r/core": "~14.2.0-prerelease.
|
|
201
|
-
"@o3r/eslint-plugin": "~14.2.0-prerelease.
|
|
202
|
-
"@o3r/localization": "~14.2.0-prerelease.
|
|
203
|
-
"@o3r/test-helpers": "~14.2.0-prerelease.
|
|
199
|
+
"@o3r/build-helpers": "~14.2.0-prerelease.2",
|
|
200
|
+
"@o3r/core": "~14.2.0-prerelease.2",
|
|
201
|
+
"@o3r/eslint-plugin": "~14.2.0-prerelease.2",
|
|
202
|
+
"@o3r/localization": "~14.2.0-prerelease.2",
|
|
203
|
+
"@o3r/test-helpers": "~14.2.0-prerelease.2",
|
|
204
204
|
"@playwright/test": "~1.58.0",
|
|
205
205
|
"@schematics/angular": "~21.2.0",
|
|
206
206
|
"@standard-schema/spec": "~1.1.0",
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
1
|
+
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
2
2
|
import type { NgAddSchematicsSchema } from '../../../schematics/ng-add/schema';
|
|
3
3
|
/**
|
|
4
4
|
* List of dependencies needed to run jest
|
|
5
5
|
* @param eslintDependencies
|
|
6
6
|
*/
|
|
7
7
|
export declare const jestDependencies: (eslintDependencies: boolean) => string[];
|
|
8
|
+
/**
|
|
9
|
+
* Set jest files and script in the generated library.
|
|
10
|
+
* @param projectName
|
|
11
|
+
*/
|
|
12
|
+
export declare function setUpJestForAngularJson(projectName: string): (tree: Tree) => import("@angular-devkit/schematics/src/tree/interface").Tree;
|
|
8
13
|
/**
|
|
9
14
|
* Setup jest as recommended
|
|
10
15
|
* @param options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,IAAI,EAGJ,IAAI,EAEL,MAAM,4BAA4B,CAAC;AAQpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,oBAAoB,OAAO,aAS3D,CAAC;AAiBF;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,IACjD,MAAM,IAAI,kEAkBnB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAyC9D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jestDependencies = void 0;
|
|
4
|
+
exports.setUpJestForAngularJson = setUpJestForAngularJson;
|
|
4
5
|
exports.setupJest = setupJest;
|
|
5
6
|
const path = require("node:path");
|
|
6
7
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
@@ -23,15 +24,40 @@ exports.jestDependencies = jestDependencies;
|
|
|
23
24
|
/**
|
|
24
25
|
* Run jest on 'npm/yarn run test'
|
|
25
26
|
* @param workingDirectory
|
|
27
|
+
* @param isAngular
|
|
28
|
+
* @param projectName
|
|
26
29
|
*/
|
|
27
|
-
function setupJestScript(workingDirectory) {
|
|
30
|
+
function setupJestScript(workingDirectory, isAngular, projectName) {
|
|
28
31
|
return (tree) => {
|
|
29
32
|
const packageJsonFile = tree.readJson(`${workingDirectory}/package.json`);
|
|
30
33
|
packageJsonFile.scripts ||= {};
|
|
31
|
-
packageJsonFile.scripts.test = 'jest';
|
|
34
|
+
packageJsonFile.scripts.test = isAngular ? `ng test ${projectName}` : 'jest';
|
|
32
35
|
tree.overwrite(`${workingDirectory}/package.json`, JSON.stringify(packageJsonFile, null, 2));
|
|
33
36
|
};
|
|
34
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Set jest files and script in the generated library.
|
|
40
|
+
* @param projectName
|
|
41
|
+
*/
|
|
42
|
+
function setUpJestForAngularJson(projectName) {
|
|
43
|
+
return (tree) => {
|
|
44
|
+
const angularFile = tree.readJson('/angular.json');
|
|
45
|
+
const project = angularFile.projects[projectName];
|
|
46
|
+
if (project) {
|
|
47
|
+
project.architect ||= {};
|
|
48
|
+
project.architect.test = {
|
|
49
|
+
builder: '@angular-builders/jest:run',
|
|
50
|
+
options: {
|
|
51
|
+
tsConfig: `tsconfig.spec.json`,
|
|
52
|
+
config: `jest.config.js`,
|
|
53
|
+
setupFilesAfterEnv: './testing/setup-jest.ts'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
tree.overwrite('/angular.json', JSON.stringify(angularFile, null, 2));
|
|
57
|
+
}
|
|
58
|
+
return tree;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
35
61
|
/**
|
|
36
62
|
* Setup jest as recommended
|
|
37
63
|
* @param options
|
|
@@ -44,19 +70,23 @@ function setupJest(options) {
|
|
|
44
70
|
throw new schematics_2.O3rCliError(`Could not find working directory for project ${options.projectName || ''}`);
|
|
45
71
|
}
|
|
46
72
|
const rootRelativePath = path.posix.relative(workingDirectory, tree.root.path.replace(/^\//, './'));
|
|
73
|
+
const isAngularSetup = tree.exists('/angular.json');
|
|
47
74
|
const setupJestInProject = (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./jest/templates/project'), [
|
|
48
75
|
(0, schematics_1.template)({
|
|
49
76
|
...options,
|
|
50
77
|
rootRelativePath,
|
|
51
|
-
isAngularSetup
|
|
78
|
+
isAngularSetup
|
|
52
79
|
}),
|
|
53
80
|
(0, schematics_1.move)(workingDirectory),
|
|
54
81
|
(0, schematics_1.renameTemplateFiles)()
|
|
55
82
|
]), schematics_1.MergeStrategy.Overwrite);
|
|
56
|
-
const rules =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
83
|
+
const rules = options.projectName
|
|
84
|
+
? [
|
|
85
|
+
setupJestScript(workingDirectory, isAngularSetup, options.projectName),
|
|
86
|
+
setupJestInProject,
|
|
87
|
+
setUpJestForAngularJson(options.projectName)
|
|
88
|
+
]
|
|
89
|
+
: [];
|
|
60
90
|
if (tree.exists('/jest.config.js')) {
|
|
61
91
|
context.logger.info('Jest configuration files already exist at the root of the project.');
|
|
62
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":";;;AA2DA,0DAmBC;AAMD,8BAyCC;AA7HD,kCAAkC;AAClC,2DAYoC;AACpC,gDAGyB;AAQzB;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,kBAA2B,EAAE,EAAE,CAAC;IAC/D,wBAAwB;IACxB,aAAa;IACb,MAAM;IACN,wBAAwB;IACxB,qBAAqB;IACrB,WAAW;IACX,SAAS;IACT,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE;CACpD,CAAC;AATW,QAAA,gBAAgB,oBAS3B;AAEF;;;;;GAKG;AACH,SAAS,eAAe,CAAC,gBAAwB,EAAE,SAAkB,EAAE,WAAmB;IACxF,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,gBAAgB,eAAe,CAAgB,CAAC;QACzF,eAAe,CAAC,OAAO,KAAK,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