@o3r/testing 14.6.0-prerelease.55 → 14.6.0-prerelease.57
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/mocks/mock-component-generator.js +2 -1
- package/mocks/mock-component-generator.js.map +1 -1
- package/package.json +44 -44
- package/schematics/add-functions-to-fixture/index.js +2 -1
- package/schematics/add-functions-to-fixture/index.js.map +1 -1
- package/schematics/fixture-to-component/index.js +2 -1
- package/schematics/fixture-to-component/index.js.map +1 -1
- package/schematics/ng-add/fixture/index.js +2 -1
- package/schematics/ng-add/fixture/index.js.map +1 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +5 -3
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/jest/index.d.ts.map +1 -1
- package/schematics/ng-add/jest/index.js +17 -2
- package/schematics/ng-add/jest/index.js.map +1 -1
- package/schematics/ng-add/jest/templates/workspace/tsconfig.jest.json.template +3 -1
- package/schematics/ng-add/playwright/index.js +2 -1
- package/schematics/ng-add/playwright/index.js.map +1 -1
- package/schematics/ng-add/playwright/templates/e2e-playwright/playwright-config.ts.template +1 -1
- package/tools/path-replacement/path-replacement.js +3 -2
- package/tools/path-replacement/path-replacement.js.map +1 -1
- package/visual-test/visual-test.js +4 -3
- package/visual-test/visual-test.js.map +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateMockComponent = generateMockComponent;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const core_1 = require("@angular/core");
|
|
5
6
|
const forms_1 = require("@angular/forms");
|
|
6
|
-
const ts = require("typescript");
|
|
7
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
8
|
/**
|
|
8
9
|
* Determine if the node in an input field
|
|
9
10
|
* @param node Typescript AST Node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;AAmIA,sDAyCC
|
|
1
|
+
{"version":3,"file":"mock-component-generator.js","sourceRoot":"","sources":["../../src/mocks/mock-component-generator.ts"],"names":[],"mappings":";;AAmIA,sDAyCC;;AA5KD,wCAKuB;AACvB,0CAEwB;AACxB,uDAAiC;AAEjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAa,EAAE,MAAqB;IACvD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAa,EAAE,MAAqB;IACxD,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,WAAoB,EAAE,SAAuB,EAAE,MAAqB;IACrF,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACvG,IAAI,eAAe,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,IAAI,IAAwB,CAAC;QAC7B,WAAW,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE;YAChC,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH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,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG;QAKX;YACE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBACjB,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAE,IAAY,CAAC,UAAU,CAAC,GAAG,IAAI,mBAAY,EAAO,CAAC,CAAC;YAChF,IAAI,MAAM,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAC5C,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;gBAC3B,IAAI,CAAC,gBAAgB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;gBACjC,IAAI,CAAC,iBAAiB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;KACF,CAAC;IAEF,OAAO,IAAA,gBAAS,EAAC;QACf,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE;QAC3C,MAAM;QACN,OAAO;QACP,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,sBAAsB,CAAC;YAC1C,CAAC,CAAC;gBACA,SAAS,EAAE;oBACT;wBACE,OAAO,EAAE,yBAAiB;wBAC1B,WAAW,EAAE,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;wBACnC,KAAK,EAAE,IAAI;qBACZ;iBACF;aACF;YACD,CAAC,CAAC,EAAE;KACP,CAAC,CAAC,IAAI,CAAY,CAAC;AACtB,CAAC","sourcesContent":["import {\n Component,\n EventEmitter,\n forwardRef,\n Type,\n} from '@angular/core';\nimport {\n NG_VALUE_ACCESSOR,\n} from '@angular/forms';\nimport * as ts from 'typescript';\n\n/**\n * Determine if the node in an input field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isInputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Input');\n}\n\n/**\n * Determine if the node in an output field\n * @param node Typescript AST Node\n * @param source Typescript source file\n */\nfunction isOutputNode(node: ts.Node, source: ts.SourceFile): node is ts.Decorator {\n return ts.isDecorator(node) && node.getText(source).startsWith('@Output');\n}\n\n/**\n * Get the name of the input / output\n * @param currentNode Typescript AST Node\n * @param decorator Current Input/Output decorator node\n * @param source Typescript source file\n */\nfunction getIOName(currentNode: ts.Node, decorator: ts.Decorator, source: ts.SourceFile): string | undefined {\n const nameInDecorator = decorator.getText(source).match(/@(input|output) *\\( *([\"'](.*)[\"'])? *\\) */i);\n if (nameInDecorator && nameInDecorator[3]) {\n return nameInDecorator[3];\n } else {\n let name: string | undefined;\n currentNode.forEachChild((node) => {\n if (ts.isIdentifier(node)) {\n name = node.getText(source);\n }\n });\n return name;\n }\n}\n\n/**\n * Get the list of Input and Output of a component\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n */\nfunction parseIO(parentNode: ts.Node, source: ts.SourceFile): { outputs: string[]; inputs: string[] } {\n const outputs: string[] = [];\n const inputs: string[] = [];\n\n parentNode.forEachChild((node) => {\n if (isInputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n inputs.push(name);\n }\n } else if (isOutputNode(node, source)) {\n const name = getIOName(parentNode, node, source);\n if (name) {\n outputs.push(name);\n }\n } else {\n const childrenResult = parseIO(node, source);\n inputs.push(...childrenResult.inputs);\n outputs.push(...childrenResult.outputs);\n }\n });\n\n return {\n outputs,\n inputs\n };\n}\n\n/**\n * Get the selector of an angular class\n * @param parentNode Typescript AST Node\n * @param source Typescript source file\n * @param isInDecorator true if the recursive execution is in a decorator\n * @param isInComponentConfig true if the recursive execution is in a component decorator configuration\n */\nfunction getSelector(parentNode: ts.Node, source: ts.SourceFile, isInDecorator = false, isInComponentConfig = false) {\n let foundDecorator = false;\n let foundSelector = false;\n let ret: string | undefined;\n parentNode.forEachChild((node) => {\n if (isInDecorator && isInComponentConfig && ts.isIdentifier(node) && node.getText(source) === 'selector') {\n foundSelector = true;\n } else if (foundSelector && ts.isStringLiteral(node)) {\n ret = node.getText(source).replace(/[\"']/gi, '');\n } else if (isInDecorator && ts.isIdentifier(node) && node.getText(source) === 'Component') {\n foundDecorator = true;\n } else if (isInDecorator && foundDecorator && ts.isObjectLiteralExpression(node)) {\n ret = ret || getSelector(node, source, isInDecorator, true);\n } else {\n ret = ret || getSelector(node, source, isInDecorator || ts.isDecorator(node), isInComponentConfig);\n }\n });\n return ret;\n}\n\n/**\n * Generate a mock class base on a component file\n * @param componentPath Path to the component file to mock\n * @param config Object containing the following configurations:\n * template: should be provided if the template contain `<ng-content></ng-content>`\n * isControlValueAccessor: should be provided if the component extends ControlValueAccessor\n * @param config.template\n * @param config.isControlValueAccessor\n * @example\n * ```typescript\n * // hero.ts\n * \\@Component({selector: 'hero'})\n * class HeroComponent {\n * \\@Input() name: string;\n * \\@Output() doSomething: EventEmitter<void>\n * }\n *\n * // mock generation\n * class MockComponent extends generateMockComponent('hero.ts') {}\n * ```\n */\nexport function generateMockComponent<T = Record<string, unknown>>(componentPath: string, config?: { template?: string; isControlValueAccessor?: boolean }): Type<T> {\n const program = ts.createProgram([componentPath], {});\n const source = program.getSourceFile(componentPath);\n if (!source) {\n throw new Error('No Source found');\n }\n\n const { outputs, inputs } = parseIO(source, source);\n const mock = class {\n public writeValue: any;\n public registerOnChange: any;\n public registerOnTouched: any;\n\n constructor() {\n Object.keys(outputs)\n .forEach((outputName) => (this as any)[outputName] = new EventEmitter<any>());\n if (config && config.isControlValueAccessor) {\n this.writeValue = () => {};\n this.registerOnChange = () => {};\n this.registerOnTouched = () => {};\n }\n }\n };\n\n return Component({\n template: config?.template || '',\n selector: getSelector(source, source) || '',\n inputs,\n outputs,\n ...(config && config.isControlValueAccessor)\n ? {\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => mock),\n multi: true\n }\n ]\n }\n : {}\n })(mock) as Type<T>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/testing",
|
|
3
|
-
"version": "14.6.0-prerelease.
|
|
3
|
+
"version": "14.6.0-prerelease.57",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -92,32 +92,32 @@
|
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@amadeus-it-group/kassette": "^1.7.0",
|
|
95
|
-
"@angular-devkit/core": "^
|
|
96
|
-
"@angular-devkit/schematics": "^
|
|
97
|
-
"@angular/animations": "^
|
|
98
|
-
"@angular/cli": "^
|
|
99
|
-
"@angular/common": "^
|
|
100
|
-
"@angular/core": "^
|
|
101
|
-
"@angular/forms": "^
|
|
102
|
-
"@angular/platform-browser": "^
|
|
95
|
+
"@angular-devkit/core": "^22.0.0",
|
|
96
|
+
"@angular-devkit/schematics": "^22.0.0",
|
|
97
|
+
"@angular/animations": "^22.0.0",
|
|
98
|
+
"@angular/cli": "^22.0.0",
|
|
99
|
+
"@angular/common": "^22.0.0",
|
|
100
|
+
"@angular/core": "^22.0.0",
|
|
101
|
+
"@angular/forms": "^22.0.0",
|
|
102
|
+
"@angular/platform-browser": "^22.0.0",
|
|
103
103
|
"@jsverse/transloco": "^8.0.0",
|
|
104
104
|
"@material/slider": "^14.0.0",
|
|
105
|
-
"@ngrx/store": "
|
|
105
|
+
"@ngrx/store": "22.0.0-rc.0",
|
|
106
106
|
"@ngx-translate/core": "^15.0.0 || ~16.0.4",
|
|
107
|
-
"@o3r/core": "~14.6.0-prerelease.
|
|
108
|
-
"@o3r/eslint-config": "~14.6.0-prerelease.
|
|
109
|
-
"@o3r/localization": "~14.6.0-prerelease.
|
|
110
|
-
"@o3r/schematics": "~14.6.0-prerelease.
|
|
111
|
-
"@o3r/transloco": "~14.6.0-prerelease.
|
|
107
|
+
"@o3r/core": "~14.6.0-prerelease.57",
|
|
108
|
+
"@o3r/eslint-config": "~14.6.0-prerelease.57",
|
|
109
|
+
"@o3r/localization": "~14.6.0-prerelease.57",
|
|
110
|
+
"@o3r/schematics": "~14.6.0-prerelease.57",
|
|
111
|
+
"@o3r/transloco": "~14.6.0-prerelease.57",
|
|
112
112
|
"@playwright/test": "^1.49.0",
|
|
113
|
-
"@schematics/angular": "^
|
|
113
|
+
"@schematics/angular": "^22.0.0",
|
|
114
114
|
"eslint": "~9.39.0",
|
|
115
115
|
"pixelmatch": "^7.0.0",
|
|
116
116
|
"pngjs": "^7.0.0",
|
|
117
117
|
"rxjs": "^7.8.1",
|
|
118
118
|
"temporal-polyfill": "^0.3.0",
|
|
119
119
|
"type-fest": "^5.3.1",
|
|
120
|
-
"typescript": "^
|
|
120
|
+
"typescript": "^6.0.0"
|
|
121
121
|
},
|
|
122
122
|
"peerDependenciesMeta": {
|
|
123
123
|
"@amadeus-it-group/kassette": {
|
|
@@ -182,41 +182,41 @@
|
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
"dependencies": {
|
|
185
|
-
"@o3r/schematics": "~14.6.0-prerelease.
|
|
185
|
+
"@o3r/schematics": "~14.6.0-prerelease.57",
|
|
186
186
|
"esbuild": "~0.28.0",
|
|
187
187
|
"tslib": "^2.6.2"
|
|
188
188
|
},
|
|
189
189
|
"devDependencies": {
|
|
190
190
|
"@amadeus-it-group/kassette": "^1.7.0",
|
|
191
|
-
"@angular-devkit/build-angular": "~
|
|
192
|
-
"@angular-devkit/core": "~
|
|
193
|
-
"@angular-devkit/schematics": "~
|
|
194
|
-
"@angular/cli": "~
|
|
195
|
-
"@angular/common": "~
|
|
196
|
-
"@angular/compiler": "~
|
|
197
|
-
"@angular/compiler-cli": "~
|
|
198
|
-
"@angular/core": "~
|
|
199
|
-
"@angular/forms": "~
|
|
200
|
-
"@angular/platform-browser": "~
|
|
201
|
-
"@angular/platform-browser-dynamic": "~
|
|
191
|
+
"@angular-devkit/build-angular": "~22.0.4",
|
|
192
|
+
"@angular-devkit/core": "~22.0.4",
|
|
193
|
+
"@angular-devkit/schematics": "~22.0.4",
|
|
194
|
+
"@angular/cli": "~22.0.4",
|
|
195
|
+
"@angular/common": "~22.0.4",
|
|
196
|
+
"@angular/compiler": "~22.0.4",
|
|
197
|
+
"@angular/compiler-cli": "~22.0.4",
|
|
198
|
+
"@angular/core": "~22.0.4",
|
|
199
|
+
"@angular/forms": "~22.0.4",
|
|
200
|
+
"@angular/platform-browser": "~22.0.4",
|
|
201
|
+
"@angular/platform-browser-dynamic": "~22.0.4",
|
|
202
202
|
"@babel/core": "~7.29.0",
|
|
203
203
|
"@babel/preset-typescript": "~7.29.0",
|
|
204
204
|
"@compodoc/compodoc": "^1.1.32",
|
|
205
205
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
206
206
|
"@jsverse/transloco": "~8.3.0",
|
|
207
207
|
"@material/slider": "^14.0.0",
|
|
208
|
-
"@ngrx/store": "
|
|
208
|
+
"@ngrx/store": "22.0.0-rc.0",
|
|
209
209
|
"@ngx-translate/core": "~16.0.4",
|
|
210
|
-
"@nx/eslint-plugin": "~
|
|
211
|
-
"@nx/jest": "~
|
|
212
|
-
"@o3r/build-helpers": "~14.6.0-prerelease.
|
|
213
|
-
"@o3r/core": "~14.6.0-prerelease.
|
|
214
|
-
"@o3r/eslint-plugin": "~14.6.0-prerelease.
|
|
215
|
-
"@o3r/localization": "~14.6.0-prerelease.
|
|
216
|
-
"@o3r/test-helpers": "~14.6.0-prerelease.
|
|
217
|
-
"@o3r/transloco": "~14.6.0-prerelease.
|
|
210
|
+
"@nx/eslint-plugin": "~23.1.0",
|
|
211
|
+
"@nx/jest": "~23.1.0",
|
|
212
|
+
"@o3r/build-helpers": "~14.6.0-prerelease.57",
|
|
213
|
+
"@o3r/core": "~14.6.0-prerelease.57",
|
|
214
|
+
"@o3r/eslint-plugin": "~14.6.0-prerelease.57",
|
|
215
|
+
"@o3r/localization": "~14.6.0-prerelease.57",
|
|
216
|
+
"@o3r/test-helpers": "~14.6.0-prerelease.57",
|
|
217
|
+
"@o3r/transloco": "~14.6.0-prerelease.57",
|
|
218
218
|
"@playwright/test": "~1.61.0",
|
|
219
|
-
"@schematics/angular": "~
|
|
219
|
+
"@schematics/angular": "~22.0.0",
|
|
220
220
|
"@standard-schema/spec": "~1.1.0",
|
|
221
221
|
"@stylistic/eslint-plugin": "~5.10.0",
|
|
222
222
|
"@swc/helpers": "~0.5.17",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
"@types/pixelmatch": "^5.2.3",
|
|
226
226
|
"@types/pngjs": "^6.0.0",
|
|
227
227
|
"@typescript-eslint/parser": "~8.65.0",
|
|
228
|
-
"angular-eslint": "~
|
|
228
|
+
"angular-eslint": "~22.0.0",
|
|
229
229
|
"concurrently": "^9.2.3",
|
|
230
230
|
"cpy-cli": "^6.0.0",
|
|
231
231
|
"eslint": "~9.39.0",
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
"jest-util": "~30.4.0",
|
|
248
248
|
"jsdom": "~27.4.0",
|
|
249
249
|
"jsonc-eslint-parser": "~2.4.0",
|
|
250
|
-
"nx": "~
|
|
250
|
+
"nx": "~23.1.0",
|
|
251
251
|
"pixelmatch": "^7.0.0",
|
|
252
252
|
"pngjs": "^7.0.0",
|
|
253
253
|
"rxjs": "^7.8.1",
|
|
@@ -255,11 +255,11 @@
|
|
|
255
255
|
"temporal-polyfill": "^0.3.0",
|
|
256
256
|
"ts-jest": "~29.4.0",
|
|
257
257
|
"type-fest": "^5.3.1",
|
|
258
|
-
"typescript": "~
|
|
258
|
+
"typescript": "~6.0.3",
|
|
259
259
|
"typescript-eslint": "~8.65.0"
|
|
260
260
|
},
|
|
261
261
|
"generatorDependencies": {
|
|
262
|
-
"@angular-builders/jest": "~
|
|
262
|
+
"@angular-builders/jest": "~22.0.0",
|
|
263
263
|
"@types/jest": "~30.0.0",
|
|
264
264
|
"jest": "~30.4.0",
|
|
265
265
|
"jest-environment-jsdom": "~30.4.0",
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"migrations": "./migration.json"
|
|
275
275
|
},
|
|
276
276
|
"engines": {
|
|
277
|
-
"node": "^22.
|
|
277
|
+
"node": "^22.22.3 || ^24.15.0 || ^26.0.0"
|
|
278
278
|
},
|
|
279
279
|
"contributors": [
|
|
280
280
|
{
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAddFunctionsToFixture = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
6
|
const schematics_2 = require("@o3r/schematics");
|
|
6
|
-
const ts = require("typescript");
|
|
7
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
8
|
const helpers_1 = require("./helpers");
|
|
8
9
|
const models_1 = require("./models");
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/add-functions-to-fixture/index.ts"],"names":[],"mappings":";;;;AAAA,2DAKoC;AACpC,gDAIyB;AACzB,uDAAiC;AACjC,uCAGmB;AACnB,qCAEkB;AAKlB;;;GAGG;AACH,SAAS,yBAAyB,CAAC,OAAgD;IACjF,OAAO,IAAA,kBAAK,EAAC;QACX,CAAC,IAAU,EAAE,EAAE;YACb,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvB,MAAM,IAAI,wBAAW,CAAC,wBAAwB,IAAI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9B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,2BAAc,GAAE;KAC/C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACU,QAAA,uBAAuB,GAAG,IAAA,iCAAoB,EAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAddFixture = void 0;
|
|
4
4
|
exports.ngAddFixtureFn = ngAddFixtureFn;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
5
6
|
const node_path_1 = require("node:path");
|
|
6
7
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
7
8
|
const schematics_2 = require("@o3r/schematics");
|
|
8
9
|
const change_1 = require("@schematics/angular/utility/change");
|
|
9
|
-
const ts = require("typescript");
|
|
10
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
10
11
|
const checkFixture = (componentPath, tree, baseFileName) => {
|
|
11
12
|
const files = [
|
|
12
13
|
node_path_1.posix.join((0, node_path_1.dirname)(componentPath), `${baseFileName}-fixture.ts`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":";;;AAqDA,wCAmGC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/fixture-to-component/index.ts"],"names":[],"mappings":";;;AAqDA,wCAmGC;;AAxJD,yCAImB;AACnB,2DAcoC;AACpC,gDAUyB;AACzB,+DAG4C;AAC5C,uDAAiC;AAKjC,MAAM,YAAY,GAAG,CAAC,aAAqB,EAAE,IAAU,EAAE,YAAoB,EAAE,EAAE;IAC/E,MAAM,KAAK,GAAG;QACZ,iBAAK,CAAC,IAAI,CAAC,IAAA,mBAAO,EAAC,aAAa,CAAC,EAAE,GAAG,YAAY,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AAU,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;yBAC3C,UAAU,CACT,gDAAgD,EAChD,gCAAgC,UAAU,CAAC,gBAAgB,kDAAkD,CAC9G;yBACA,UAAU,CACT,6CAA6C,EAC7C,8CAA8C,CAC/C,CAAC;oBAEJ,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;oBAEzC,OAAO,IAAI,CAAC;gBACd,CAAC;aACF,CAAC,CAAC;YAEH,OAAO,IAAA,kBAAK,EAAC;gBACX,sBAAsB;gBACtB,cAAc;gBACd,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,2BAAc,GAAE;aAC/C,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,6BAAgB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;gBACzD,MAAM,sBAAsB,GAAG,MAAM,IAAA,8CAAiC,GAAE,CAAC;gBACzE,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,OAAO,IAAA,kBAAK,EAAC;wBACX,IAAA,8BAAiB,EAAC,WAAW,EAAE,mBAAmB,EAAE;4BAClD,IAAI,EAAE,OAAO,CAAC,IAAI;yBACnB,CAAC;wBACF,cAAc,CAAC,OAAO,CAAC;qBACxB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACU,QAAA,YAAY,GAAG,IAAA,iCAAoB,EAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateFixtureConfig = updateFixtureConfig;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
6
|
const schematics_2 = require("@o3r/schematics");
|
|
6
|
-
const ts = require("typescript");
|
|
7
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
8
|
/**
|
|
8
9
|
* Add fixture configuration
|
|
9
10
|
* @param options {@link RuleFactory.options}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":";;AAqBA,kDAuFC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/fixture/index.ts"],"names":[],"mappings":";;AAqBA,kDAuFC;;AA5GD,2DAKoC;AACpC,gDAGyB;AAIzB,uDAAiC;AAEjC;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAkG;IACpI,MAAM,QAAQ,GAAG,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;IAClE;;;;OAIG;IACH,MAAM,kBAAkB,GAAS,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QACzE,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAEnH,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QAED,MAAM,UAAU,GAAG,gBAAgB,CAAC,SAAS,IAAI,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC;QACjF,MAAM,YAAY,GAAuB,UAAU,IAAI,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;QAEzG,IAAI,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAiB,CAAC;YACjE,YAAY,CAAC,eAAe,KAAK,EAAE,C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EAAE;YACtK,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACnB,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEzF,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,IAAA,kBAAK,EAAC,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,IAAI,EAGL,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AA4IpC;;;GAGG;AACH,eAAO,MAAM,KAAK,wBAAgC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAdd = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
7
|
const prompt_1 = require("@angular/cli/src/utilities/prompt");
|
|
7
8
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
8
9
|
const schematics_2 = require("@o3r/schematics");
|
|
@@ -22,7 +23,8 @@ const devDependenciesToInstall = [
|
|
|
22
23
|
'uuid',
|
|
23
24
|
'@angular-devkit/build-angular',
|
|
24
25
|
'@angular/core',
|
|
25
|
-
'@angular/common'
|
|
26
|
+
'@angular/common',
|
|
27
|
+
'@types/node'
|
|
26
28
|
];
|
|
27
29
|
/**
|
|
28
30
|
* Add Otter testing to an Angular Project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,8DAE2C;AAC3C,2DAMoC;AACpC,gDAWyB;AAOzB,uCAEmB;AACnB,iCAGgB;AAChB,6CAGsB;AAEtB;;GAEG;AACH,MAAM,qBAAqB,GAAa,EAAE,CAAC;AAE3C;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,YAAY;IACZ,OAAO;IACP,MAAM;IACN,+BAA+B;IAC/B,eAAe;IACf,iBAAiB;IACjB,aAAa;CACd,CAAC;AAEF;;;GAGG;AACH,SAAS,OAAO,CAAC,OAA8B;IAC7C,OAAO,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;YAChF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAgB,CAAC;YAC1G,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnH,MAA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AAK,CAAC;;+GAEoF,CAAC,CAAC;YAC3G,MAAM,IAAI,wBAAW,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACU,QAAA,KAAK,GAAG,IAAA,iCAAoB,EAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CAuD9D"}
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.jestDependencies = void 0;
|
|
4
4
|
exports.setUpJestForAngularJson = setUpJestForAngularJson;
|
|
5
5
|
exports.setupJest = setupJest;
|
|
6
|
-
const
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
8
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
8
9
|
const schematics_2 = require("@o3r/schematics");
|
|
9
10
|
/**
|
|
@@ -84,7 +85,21 @@ function setupJest(options) {
|
|
|
84
85
|
? [
|
|
85
86
|
setupJestScript(workingDirectory, isAngularSetup, options.projectName),
|
|
86
87
|
setupJestInProject,
|
|
87
|
-
setUpJestForAngularJson(options.projectName)
|
|
88
|
+
setUpJestForAngularJson(options.projectName),
|
|
89
|
+
() => {
|
|
90
|
+
if (tree.exists(`${workingDirectory}/tsconfig.spec.json`)) {
|
|
91
|
+
const tsConfigSpec = tree.readJson(`${workingDirectory}/tsconfig.spec.json`);
|
|
92
|
+
if (tsConfigSpec.compilerOptions.types) {
|
|
93
|
+
delete tsConfigSpec.compilerOptions.types;
|
|
94
|
+
}
|
|
95
|
+
tsConfigSpec.extends = `${rootRelativePath}/tsconfig.jest.json`;
|
|
96
|
+
tsConfigSpec.include ??= [];
|
|
97
|
+
if (!tsConfigSpec.include.includes('testing/setup-jest.ts')) {
|
|
98
|
+
tsConfigSpec.include.push('testing/setup-jest.ts');
|
|
99
|
+
}
|
|
100
|
+
tree.overwrite(`${workingDirectory}/tsconfig.spec.json`, JSON.stringify(tsConfigSpec, null, 2));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
88
103
|
]
|
|
89
104
|
: [];
|
|
90
105
|
if (tree.exists('/jest.config.js')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":";;;AA2DA,0DAmBC;AAMD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/jest/index.ts"],"names":[],"mappings":";;;AA2DA,0D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AAC,IAAA,gBAAG,EAAC,4BAA4B,CAAC,EAAE;gBAC5D,IAAA,qBAAQ,EAAC;oBACP,GAAG,OAAO;oBACV,YAAY,EAAE,KAAK,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC,EAAE;iBACtH,CAAC;gBACF,IAAA,iBAAI,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;gBACpB,IAAA,gCAAmB,GAAE;aACtB,CAAC,EAAE,0BAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAA,kBAAK,EAAC,KAAK,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playwrightDependencies = void 0;
|
|
4
4
|
exports.updatePlaywright = updatePlaywright;
|
|
5
|
-
const
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
7
|
const core_1 = require("@angular-devkit/core");
|
|
7
8
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
8
9
|
const schematics_2 = require("@o3r/schematics");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/playwright/index.ts"],"names":[],"mappings":";;;AAsCA,4CAkDC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/playwright/index.ts"],"names":[],"mappings":";;;AAsCA,4CAkDC;;AAxFD,wDAAkC;AAClC,+CAE8B;AAC9B,2DAWoC;AACpC,gDAIyB;AAKzB;;GAEG;AACU,QAAA,sBAAsB,GAAG;IACpC,kBAAkB;IAClB,aAAa;IACb,QAA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ED,iBAAiB;QACjB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC;YAC9F,MAAM,YAAY,GAAG,GAAG,IAAA,8BAAiB,GAAE,YAAY,CAAC;YACxD,MAAM,OAAO,GAAG,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,IAAA,+BAAkB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3G,MAAM,UAAU,GAAG,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,MAAM,CAAC;YAEtE,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,wBAAwB,CAAC,EAAE;gBAC1D,IAAA,qBAAQ,EAAC;oBACP,GAAG,cAAO;oBACV,UAAU;oBACV,YAAY;iBACb,CAAC;gBACF,IAAA,gCAAmB,GAAE;gBACrB,IAAA,iBAAI,EAAC,gBAAgB,CAAC;aACvB,CAAC,CAAC;YAEH,OAAO,IAAA,sBAAS,EAAC,cAAc,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3E,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adjustPath = adjustPath;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
5
6
|
const node_module_1 = require("node:module");
|
|
6
|
-
const path = require("node:path");
|
|
7
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
8
|
const node_vm_1 = require("node:vm");
|
|
8
9
|
const esbuild_1 = require("esbuild");
|
|
9
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;AA6EA,gCA8CC
|
|
1
|
+
{"version":3,"file":"path-replacement.js","sourceRoot":"","sources":["../../../src/tools/path-replacement/path-replacement.ts"],"names":[],"mappings":";;AA6EA,gCA8CC;;AA3HD,oDAA8B;AAC9B,6CAGqB;AACrB,wDAAkC;AAClC,qCAGiB;AACjB,qCAGiB;AAEjB;;;GAGG;AACH,SAAS,cAAc;IACrB,MAAM,OAAO,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE7D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC;YACH,MAAM,KAAK,GAAI,UAAsC,CAAC,GAAG,CAAC,CAAC;YAC3D,IAAI,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;YAAC,MAAM,CAAC;gBACP,kEAAkE;gBAClE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kEAAkE;QACpE,CAAC;IACH,CAAC;IAED,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC;IAC5B,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IAEhC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,IAAY,EAAE,OAAe;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IACjC,MAAM,UAAU,GAAG,IAAI,oBAAM,CAAC,QAAQ,EAA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s';\nimport {\n createRequire,\n Module,\n} from 'node:module';\nimport * as path from 'node:path';\nimport {\n createContext,\n Script,\n} from 'node:vm';\nimport {\n TransformOptions,\n transformSync,\n} from 'esbuild';\n\n/**\n * Get the global variables of the current process\n * @returns The global variables of the current process\n */\nfunction getNodeGlobals(): Record<string, unknown> {\n const globals: Record<string, unknown> = Object.create(null);\n\n for (const key of Object.getOwnPropertyNames(globalThis)) {\n try {\n const value = (globalThis as Record<string, unknown>)[key];\n try {\n globals[key] = structuredClone(value);\n } catch {\n // Non-cloneable values (functions, symbols, etc.) - use reference\n globals[key] = value;\n }\n } catch {\n // Some properties may throw when accessed (e.g., deprecated ones)\n }\n }\n\n globals.global = globalThis;\n globals.globalThis = globalThis;\n\n return globals;\n}\n\n/**\n * Load a CommonJS module from a string.\n * @param code The module code to execute\n * @param dirname The directory to use as the module's dirname\n */\nfunction requireFromString(code: string, dirname: string): string {\n const filename = path.join(dirname, '_virtual.js');\n const mainRequire = require.main;\n const tempModule = new Module(filename, mainRequire);\n tempModule.require = createRequire(filename);\n tempModule.filename = filename;\n tempModule.paths = mainRequire?.paths ?? [];\n const context = createContext({\n ...getNodeGlobals(),\n module: tempModule,\n exports: tempModule.exports,\n require: tempModule.require.bind(tempModule),\n __dirname: dirname,\n __filename: filename\n });\n\n const script = new Script(code, {\n filename\n });\n script.runInContext(context);\n tempModule.loaded = true;\n return tempModule.exports;\n}\n\n/**\n * Switch to the needed implementation of core testing, when running e2e tests\n * transforms ESM into CJS when needed\n * @param frameworkName Name of the framework used for e2e testing (playwright)\n * @param customTransformOptions\n */\nexport function adjustPath(frameworkName: 'playwright' = 'playwright', customTransformOptions: TransformOptions = {}) {\n const modulesCache: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- No need to bind the method, we are using `apply`\n const originalRequire = Module.prototype.require;\n const regex = new RegExp(`@o3r/testing/core(?!/${frameworkName})(.*)`);\n Module.prototype.require = function (this: NodeJS.Module, id: string) {\n const newId = id.replace(regex, `@o3r/testing/core/${frameworkName}$1`);\n\n try {\n return Reflect.apply(originalRequire, this, [newId]);\n } catch {\n const paths = ([] as string[])\n .concat(this.paths, this.paths.map((i) => i.replace(/[/\\\\]node_modules$/, '')));\n\n const filePath = require.resolve(newId, { paths });\n if (!modulesCache[filePath]) {\n const fileContent = fs.readFileSync(filePath);\n const cwd = path.resolve(process.cwd(), 'src');\n // we use ESBUILD to transform it into CJS\n const trans = transformSync(fileContent.toString(), {\n loader: 'js',\n format: 'cjs',\n target: 'es2016',\n sourcesContent: true,\n sourceRoot: cwd,\n ...customTransformOptions\n });\n\n /**\n * requireFromString will execute the file apart from just returning a module\n * It can throw an exception which will prevent stop the execution\n *\n * That main blocker includes IVY-compatible libraries which have\n * no compiler facade in a global scope.\n */\n try {\n modulesCache[filePath] = requireFromString(trans.code, path.dirname(filePath));\n } catch (ex) {\n // eslint-disable-next-line no-console -- no other logger available\n console.error(ex);\n }\n }\n\n return modulesCache[filePath];\n }\n } as NodeJS.Require;\n}\n"]}
|
|
@@ -6,9 +6,10 @@ exports.saveScreenshot = saveScreenshot;
|
|
|
6
6
|
exports.writeScreenshotsDiff = writeScreenshotsDiff;
|
|
7
7
|
exports.compareScreenshot = compareScreenshot;
|
|
8
8
|
exports.o3rVisualTest = o3rVisualTest;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
11
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
12
|
+
const pixelmatch_1 = tslib_1.__importDefault(require("pixelmatch"));
|
|
12
13
|
const pngjs_1 = require("pngjs");
|
|
13
14
|
var utils_1 = require("./utils");
|
|
14
15
|
Object.defineProperty(exports, "prepareVisualTesting", { enumerable: true, get: function () { return utils_1.prepareVisualTesting; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-test.js","sourceRoot":"","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AAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAC3B,aAAqB,EACrB,wBAAgC,EAChC,MAAc,EACd,YAAoB,EACpB,oBAAoB,GAAG,SAAS,EAChC,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,KAAK,EACpB,sBAAsB,GAAG,uBAAuB;IAEhD,IAAI,YAAY,EAAE,CAAC;QACjB,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAC9E,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,wBAAwB,MAAM,CAAC,CAAC;QACpH,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1G,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport pixelmatch from 'pixelmatch';\nimport {\n PNG,\n} from 'pngjs';\n\nexport {\n prepareVisualTesting,\n toggleVisualTestingRender,\n} from './utils';\n\n/** Error types returned by visual testing comparison */\nexport interface VisualTestMessage {\n /** Error message when base image and actual image have different sizes */\n imagesSize: string;\n /** Error message when base screensot not found */\n baseImgNotFound: string;\n /** Error message when the threshold is passed */\n diffMessage: string;\n /** The message in case of success */\n success: string;\n /** The message in case of generate mode run */\n generateMode: string;\n}\n\n/** Error messages in case of visual testing failure */\nexport const visualTestMessages: Readonly<VisualTestMessage> = {\n imagesSize: 'Image sizes do not match for:',\n diffMessage: 'Diff between images is greater than threshold for:',\n baseImgNotFound: 'Base screenshot file not found:',\n success: 'Visual test successful',\n generateMode: 'Run in generate screenshot mode'\n} as const;\n\n/**\n * Object returned by a visual test operation\n */\nexport interface VisualTestResult {\n /** Error object when base image and actual image have different sizes; Contains the screenshot ffile name */\n imagesSize?: { screenshotName: string };\n /** Error object when base screensot not found. Contains the not found path as a string */\n baseScreenshotNotFound?: { baseScreenshotPath: string };\n /** Object containing the actual diff between images as percentage, the threshold and screenshot file name */\n diff?: { actualDiff: number; threshold: number; screenshotName: string };\n /** Run only generation of screenshots */\n generateMode?: boolean;\n}\n\n/**\n * Visual test matcher\n * Based on the VisualTestResult object return by compareScreenshots function, this matcher will compute the error messages\n */\nexport function toBeVisuallySimilar() {\n return {\n compare: (actual: VisualTestResult, _expected: VisualTestResult) => {\n if (actual.generateMode) {\n return {\n pass: true,\n message: visualTestMessages.generateMode\n };\n }\n if (actual.baseScreenshotNotFound) {\n return {\n pass: false,\n message: `${visualTestMessages.baseImgNotFound} ${actual.baseScreenshotNotFound.baseScreenshotPath}`\n };\n }\n if (actual.imagesSize) {\n return {\n pass: false,\n message: `${visualTestMessages.imagesSize} ${actual.imagesSize.screenshotName}`\n };\n }\n if (actual.diff && actual.diff.actualDiff > actual.diff.threshold) {\n return {\n pass: false,\n message: `${actual.diff.actualDiff} > ${actual.diff.threshold} : ${visualTestMessages.diffMessage} ${actual.diff.screenshotName}`\n };\n }\n return {\n pass: true,\n message: visualTestMessages.success\n };\n }\n };\n}\n\n/**\n * It will create a file for the passed screenshot object.\n * The path of the new file will be calculated using the parameters\n * Ex: ./dist-screenshots\\OWBooking\\windows_chrome_91\\fare-page-after-click-on-continue-0.png\n * distScreenshotsDir/scenarionName/device/filenameWithoutExtension.png\n * @param screenshot The screenshot object captured. Ex: for protractor - browser.takeScreenshot()\n * @param scenarioName E2e Scenario class name\n * @param device Details of the platform on which the test is run. If there are spaces the helper will do the concatenation. Ex: `Windows 10 chrome 89`\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param distScreenshotsDir Name of the directory to save the screenshots\n */\nexport function saveScreenshot(screenshot: string, scenarioName: string, device: string, filenameWithoutExtension: string, distScreenshotsDir = 'dist-screenshots') {\n const screenshotsDir = path.resolve(distScreenshotsDir, scenarioName, `${device.replace(/ +/g, '_')}`);\n if (!fs.existsSync(screenshotsDir)) {\n fs.mkdirSync(screenshotsDir, { recursive: true });\n }\n const fullFileName = `${filenameWithoutExtension}.png`;\n const stream = fs.createWriteStream(path.resolve(screenshotsDir, fullFileName));\n stream.write(Buffer.from(screenshot, 'base64'));\n stream.end();\n}\n\n/**\n * Write the 3 images (base/new/diff) on the reports folder\n * The path inside the reports forlder will be calculated using the parameters\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder\n * @param screenshotsDirName Name of the directory which will contain the 3 images\n * @param diff diff image\n * @param baseImage the base image\n * @param currentImg the actual taken screenshot image\n */\nexport function writeScreenshotsDiff(pathToScenarioReport: string, screenshotsDirName: string, diff: PNG, baseImage: PNG, currentImg: PNG) {\n const destScreenshotsDiffDir = path.join(pathToScenarioReport, 'screenshots-diff', screenshotsDirName);\n if (!fs.existsSync(destScreenshotsDiffDir)) {\n fs.mkdirSync(destScreenshotsDiffDir, { recursive: true });\n }\n\n const diffPath = path.resolve(destScreenshotsDiffDir, 'diff.png');\n const oldPath = path.resolve(destScreenshotsDiffDir, 'old.png');\n const newPath = path.resolve(destScreenshotsDiffDir, 'new.png');\n fs.writeFileSync(diffPath, PNG.sync.write(diff));\n fs.writeFileSync(oldPath, PNG.sync.write(baseImage));\n fs.writeFileSync(newPath, PNG.sync.write(currentImg));\n}\n\n/**\n * Compare images helper function. If the comparison fails the 3 images (base/new/diff) will be written inside the reports folder of the actual scenario\n * @param screenshot Actual captured screenshot object\n * @param baseImagePath The path to the base screenshot\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder. Used to compute the path to write diff images in case there is a diff at comparison\n * @returns An object of visual test result type\n */\nexport function compareScreenshot(screenshot: string, baseImagePath: string, threshold: number, pathToScenarioReport: string): VisualTestResult {\n const baseImageExists = fs.existsSync(baseImagePath);\n if (baseImageExists) {\n const baseImage = PNG.sync.read(fs.readFileSync(baseImagePath));\n const { width, height } = baseImage;\n const diff = new PNG({ width, height });\n\n const screenshotBuffer = Buffer.from(screenshot, 'base64');\n const currentImg = PNG.sync.read(screenshotBuffer);\n const diffDirName = path.basename(baseImagePath, '.png');\n let result;\n try {\n result = pixelmatch(baseImage.data, currentImg.data, diff.data, width, height, { threshold: 0.1 });\n } catch (err: any) {\n if (!err.toString().includes('Image sizes do not match.')) {\n throw err;\n }\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n return { imagesSize: { screenshotName: diffDirName } };\n }\n const pr = Math.round(100 * 100 * result / (width * height)) / 100;\n if (pr > threshold) {\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n }\n return { diff: { actualDiff: pr, threshold, screenshotName: diffDirName } };\n } else {\n return { baseScreenshotNotFound: { baseScreenshotPath: baseImagePath } };\n }\n}\n\n/**\n * Helper function to perform a visual test operation\n * @param screenshotObj Ex: for protractor browser.takeScreenshot()\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param device os followed by browser version - ex: `Windows 10 chrome 89`\n * @param scenarioName E2e Scenario class name\n * @param pathToScenarioReport Path used in compare mode for saving the base,new,diff images in reports in case there is a diff\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * If the diff is bigger, 3 png files will be created: base screenshot, new screenshot and diff image\n * @param generateMode If true it will generate the screenshot file without screenshots comparison\n * @param baseScreenshotsDirPath The folder path to search base screenshots; used only in compare mode\n */\nexport function o3rVisualTest(\n screenshotObj: string,\n filenameWithoutExtension: string,\n device: string,\n scenarioName: string,\n pathToScenarioReport = 'reports',\n threshold = 0,\n generateMode = false,\n baseScreenshotsDirPath = 'dist-screenshots-base'\n) {\n if (generateMode) {\n saveScreenshot(screenshotObj, scenarioName, device, filenameWithoutExtension);\n return { generateMode: true };\n } else {\n const baseImagePath = path.resolve(baseScreenshotsDirPath, scenarioName, device, `${filenameWithoutExtension}.png`);\n const visualTestResult = compareScreenshot(screenshotObj, baseImagePath, threshold, pathToScenarioReport);\n return visualTestResult;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"visual-test.js","sourceRoot":"","sources":["../../src/visual-test/visual-test.ts"],"names":[],"mappings":";;;AAqDA,kDAiCC;AAaD,wCASC;AAWD,oDAYC;AAUD,8CA4BC;AAcD,sCAkBC;;AAzMD,oDAA8B;AAC9B,wDAAkC;AAClC,oEAAoC;AACpC,iCAEe;AAEf,iCAGiB;AAFf,6GAAA,oBAAoB,OAAA;AACpB,kHAAA,yBAAyB,OAAA;AAiB3B,uDAAuD;AAC1C,QAAA,kBAAkB,GAAgC;IAC7D,UAAU,EAAE,+BAA+B;IAC3C,WAAW,EAAE,oDAAoD;IACjE,eAAe,EAAE,iCAAiC;IAClD,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,iCAAiC;CACvC,CAAC;AAgBX;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO;QACL,OAAO,EAAE,CAAC,MAAwB,EAAE,SAA2B,EAAE,EAAE;YACjE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;gBACxB,OAAO;oBACL,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,0BAAkB,CAAC,YAAY;iBACzC,CAAC;YACJ,CAAC;YACD,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAClC,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,GAAG,0BAAkB,CAAC,eAAe,IAAI,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,EAAE;iBACrG,CAAC;YACJ,CAAC;YACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,OAAO;oBACL,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,GAAG,0BAAkB,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE;iBAChF,CAAC;YACJ,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,IAAI,M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,EAAE,EAAE,CAAC;IAC9E,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,sBAAsB,EAAE,EAAE,kBAAkB,EAAE,aAAa,EAAE,EAAE,CAAC;IAC3E,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAC3B,aAAqB,EACrB,wBAAgC,EAChC,MAAc,EACd,YAAoB,EACpB,oBAAoB,GAAG,SAAS,EAChC,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,KAAK,EACpB,sBAAsB,GAAG,uBAAuB;IAEhD,IAAI,YAAY,EAAE,CAAC;QACjB,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAC9E,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,wBAAwB,MAAM,CAAC,CAAC;QACpH,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC1G,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport pixelmatch from 'pixelmatch';\nimport {\n PNG,\n} from 'pngjs';\n\nexport {\n prepareVisualTesting,\n toggleVisualTestingRender,\n} from './utils';\n\n/** Error types returned by visual testing comparison */\nexport interface VisualTestMessage {\n /** Error message when base image and actual image have different sizes */\n imagesSize: string;\n /** Error message when base screensot not found */\n baseImgNotFound: string;\n /** Error message when the threshold is passed */\n diffMessage: string;\n /** The message in case of success */\n success: string;\n /** The message in case of generate mode run */\n generateMode: string;\n}\n\n/** Error messages in case of visual testing failure */\nexport const visualTestMessages: Readonly<VisualTestMessage> = {\n imagesSize: 'Image sizes do not match for:',\n diffMessage: 'Diff between images is greater than threshold for:',\n baseImgNotFound: 'Base screenshot file not found:',\n success: 'Visual test successful',\n generateMode: 'Run in generate screenshot mode'\n} as const;\n\n/**\n * Object returned by a visual test operation\n */\nexport interface VisualTestResult {\n /** Error object when base image and actual image have different sizes; Contains the screenshot ffile name */\n imagesSize?: { screenshotName: string };\n /** Error object when base screensot not found. Contains the not found path as a string */\n baseScreenshotNotFound?: { baseScreenshotPath: string };\n /** Object containing the actual diff between images as percentage, the threshold and screenshot file name */\n diff?: { actualDiff: number; threshold: number; screenshotName: string };\n /** Run only generation of screenshots */\n generateMode?: boolean;\n}\n\n/**\n * Visual test matcher\n * Based on the VisualTestResult object return by compareScreenshots function, this matcher will compute the error messages\n */\nexport function toBeVisuallySimilar() {\n return {\n compare: (actual: VisualTestResult, _expected: VisualTestResult) => {\n if (actual.generateMode) {\n return {\n pass: true,\n message: visualTestMessages.generateMode\n };\n }\n if (actual.baseScreenshotNotFound) {\n return {\n pass: false,\n message: `${visualTestMessages.baseImgNotFound} ${actual.baseScreenshotNotFound.baseScreenshotPath}`\n };\n }\n if (actual.imagesSize) {\n return {\n pass: false,\n message: `${visualTestMessages.imagesSize} ${actual.imagesSize.screenshotName}`\n };\n }\n if (actual.diff && actual.diff.actualDiff > actual.diff.threshold) {\n return {\n pass: false,\n message: `${actual.diff.actualDiff} > ${actual.diff.threshold} : ${visualTestMessages.diffMessage} ${actual.diff.screenshotName}`\n };\n }\n return {\n pass: true,\n message: visualTestMessages.success\n };\n }\n };\n}\n\n/**\n * It will create a file for the passed screenshot object.\n * The path of the new file will be calculated using the parameters\n * Ex: ./dist-screenshots\\OWBooking\\windows_chrome_91\\fare-page-after-click-on-continue-0.png\n * distScreenshotsDir/scenarionName/device/filenameWithoutExtension.png\n * @param screenshot The screenshot object captured. Ex: for protractor - browser.takeScreenshot()\n * @param scenarioName E2e Scenario class name\n * @param device Details of the platform on which the test is run. If there are spaces the helper will do the concatenation. Ex: `Windows 10 chrome 89`\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param distScreenshotsDir Name of the directory to save the screenshots\n */\nexport function saveScreenshot(screenshot: string, scenarioName: string, device: string, filenameWithoutExtension: string, distScreenshotsDir = 'dist-screenshots') {\n const screenshotsDir = path.resolve(distScreenshotsDir, scenarioName, `${device.replace(/ +/g, '_')}`);\n if (!fs.existsSync(screenshotsDir)) {\n fs.mkdirSync(screenshotsDir, { recursive: true });\n }\n const fullFileName = `${filenameWithoutExtension}.png`;\n const stream = fs.createWriteStream(path.resolve(screenshotsDir, fullFileName));\n stream.write(Buffer.from(screenshot, 'base64'));\n stream.end();\n}\n\n/**\n * Write the 3 images (base/new/diff) on the reports folder\n * The path inside the reports forlder will be calculated using the parameters\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder\n * @param screenshotsDirName Name of the directory which will contain the 3 images\n * @param diff diff image\n * @param baseImage the base image\n * @param currentImg the actual taken screenshot image\n */\nexport function writeScreenshotsDiff(pathToScenarioReport: string, screenshotsDirName: string, diff: PNG, baseImage: PNG, currentImg: PNG) {\n const destScreenshotsDiffDir = path.join(pathToScenarioReport, 'screenshots-diff', screenshotsDirName);\n if (!fs.existsSync(destScreenshotsDiffDir)) {\n fs.mkdirSync(destScreenshotsDiffDir, { recursive: true });\n }\n\n const diffPath = path.resolve(destScreenshotsDiffDir, 'diff.png');\n const oldPath = path.resolve(destScreenshotsDiffDir, 'old.png');\n const newPath = path.resolve(destScreenshotsDiffDir, 'new.png');\n fs.writeFileSync(diffPath, PNG.sync.write(diff));\n fs.writeFileSync(oldPath, PNG.sync.write(baseImage));\n fs.writeFileSync(newPath, PNG.sync.write(currentImg));\n}\n\n/**\n * Compare images helper function. If the comparison fails the 3 images (base/new/diff) will be written inside the reports folder of the actual scenario\n * @param screenshot Actual captured screenshot object\n * @param baseImagePath The path to the base screenshot\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * @param pathToScenarioReport Path where the scenario report is saved inside reports folder. Used to compute the path to write diff images in case there is a diff at comparison\n * @returns An object of visual test result type\n */\nexport function compareScreenshot(screenshot: string, baseImagePath: string, threshold: number, pathToScenarioReport: string): VisualTestResult {\n const baseImageExists = fs.existsSync(baseImagePath);\n if (baseImageExists) {\n const baseImage = PNG.sync.read(fs.readFileSync(baseImagePath));\n const { width, height } = baseImage;\n const diff = new PNG({ width, height });\n\n const screenshotBuffer = Buffer.from(screenshot, 'base64');\n const currentImg = PNG.sync.read(screenshotBuffer);\n const diffDirName = path.basename(baseImagePath, '.png');\n let result;\n try {\n result = pixelmatch(baseImage.data, currentImg.data, diff.data, width, height, { threshold: 0.1 });\n } catch (err: any) {\n if (!err.toString().includes('Image sizes do not match.')) {\n throw err;\n }\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n return { imagesSize: { screenshotName: diffDirName } };\n }\n const pr = Math.round(100 * 100 * result / (width * height)) / 100;\n if (pr > threshold) {\n writeScreenshotsDiff(pathToScenarioReport, diffDirName, diff, baseImage, currentImg);\n }\n return { diff: { actualDiff: pr, threshold, screenshotName: diffDirName } };\n } else {\n return { baseScreenshotNotFound: { baseScreenshotPath: baseImagePath } };\n }\n}\n\n/**\n * Helper function to perform a visual test operation\n * @param screenshotObj Ex: for protractor browser.takeScreenshot()\n * @param filenameWithoutExtension file name to save the screenshot - .png will be added at the end\n * @param device os followed by browser version - ex: `Windows 10 chrome 89`\n * @param scenarioName E2e Scenario class name\n * @param pathToScenarioReport Path used in compare mode for saving the base,new,diff images in reports in case there is a diff\n * @param threshold The diff between base screenshot and the current one should not be bigger than this value.\n * If the diff is bigger, 3 png files will be created: base screenshot, new screenshot and diff image\n * @param generateMode If true it will generate the screenshot file without screenshots comparison\n * @param baseScreenshotsDirPath The folder path to search base screenshots; used only in compare mode\n */\nexport function o3rVisualTest(\n screenshotObj: string,\n filenameWithoutExtension: string,\n device: string,\n scenarioName: string,\n pathToScenarioReport = 'reports',\n threshold = 0,\n generateMode = false,\n baseScreenshotsDirPath = 'dist-screenshots-base'\n) {\n if (generateMode) {\n saveScreenshot(screenshotObj, scenarioName, device, filenameWithoutExtension);\n return { generateMode: true };\n } else {\n const baseImagePath = path.resolve(baseScreenshotsDirPath, scenarioName, device, `${filenameWithoutExtension}.png`);\n const visualTestResult = compareScreenshot(screenshotObj, baseImagePath, threshold, pathToScenarioReport);\n return visualTestResult;\n }\n}\n"]}
|