@backstage/e2e-test-utils 0.1.0-next.0
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/CHANGELOG.md +7 -0
- package/README.md +12 -0
- package/dist/playwright.cjs.js +43 -0
- package/dist/playwright.cjs.js.map +1 -0
- package/dist/playwright.d.ts +18 -0
- package/package.json +52 -0
- package/playwright/package.json +6 -0
- package/src/index.ts +16 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fs = require('fs-extra');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var getPackages = require('@manypkg/get-packages');
|
|
8
|
+
var test = require('@playwright/test');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
13
|
+
|
|
14
|
+
function generateProjects() {
|
|
15
|
+
const { root, packages } = getPackages.getPackagesSync(process.cwd());
|
|
16
|
+
const e2eTestPackages = [...root ? [root] : [], ...packages].filter((pkg) => {
|
|
17
|
+
return fs__default["default"].pathExistsSync(path.resolve(pkg.dir, "e2e-tests"));
|
|
18
|
+
});
|
|
19
|
+
return e2eTestPackages.map((pkg) => ({
|
|
20
|
+
name: pkg.packageJson.name,
|
|
21
|
+
testDir: path.resolve(pkg.dir, "e2e-tests"),
|
|
22
|
+
use: {
|
|
23
|
+
channel: "chrome"
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function failOnBrowserErrors() {
|
|
29
|
+
test.test.beforeEach(async ({ page }) => {
|
|
30
|
+
page.on("pageerror", (error) => {
|
|
31
|
+
throw new Error(`Uncaught exception on page, ${error}`);
|
|
32
|
+
});
|
|
33
|
+
page.on("console", (msg) => {
|
|
34
|
+
if (msg.type() === "error") {
|
|
35
|
+
throw new Error(`Unexpected console error message "${msg.text()}"`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.failOnBrowserErrors = failOnBrowserErrors;
|
|
42
|
+
exports.generateProjects = generateProjects;
|
|
43
|
+
//# sourceMappingURL=playwright.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.cjs.js","sources":["../src/playwright/generateProjects.ts","../src/playwright/failOnBrowserErrors.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport { PlaywrightTestConfig } from '@playwright/test';\nimport { getPackagesSync } from '@manypkg/get-packages';\nimport type { BackstagePackage } from '@backstage/cli-node';\n\n/**\n * Generates a list of playwright projects by scanning the monorepo for packages with an `e2e-tests/` folder.\n *\n * @public\n */\nexport function generateProjects(): PlaywrightTestConfig['projects'] {\n // TODO(Rugvip): Switch this over to use @backstage/cli-node once released, and support SINCE=origin/main\n const { root, packages } = getPackagesSync(process.cwd());\n const e2eTestPackages = [...(root ? [root] : []), ...packages].filter(pkg => {\n return fs.pathExistsSync(resolvePath(pkg.dir, 'e2e-tests'));\n }) as BackstagePackage[];\n\n return e2eTestPackages.map(pkg => ({\n name: pkg.packageJson.name,\n testDir: resolvePath(pkg.dir, 'e2e-tests'),\n use: {\n channel: 'chrome',\n },\n }));\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { test } from '@playwright/test';\n\n/**\n * Calling this at the top of your test file will ensure that tests fail if the browser\n * logs any errors or if there are any uncaught exceptions.\n *\n * @public\n */\nexport function failOnBrowserErrors(): void {\n test.beforeEach(async ({ page }) => {\n page.on('pageerror', error => {\n throw new Error(`Uncaught exception on page, ${error}`);\n });\n\n page.on('console', msg => {\n if (msg.type() === 'error') {\n throw new Error(`Unexpected console error message \"${msg.text()}\"`);\n }\n });\n });\n}\n"],"names":["getPackagesSync","fs","resolvePath","test"],"mappings":";;;;;;;;;;;;;AA2BO,SAAS,gBAAqD,GAAA;AAEnE,EAAA,MAAM,EAAE,IAAM,EAAA,QAAA,KAAaA,2BAAgB,CAAA,OAAA,CAAQ,KAAK,CAAA,CAAA;AACxD,EAAA,MAAM,eAAkB,GAAA,CAAC,GAAI,IAAA,GAAO,CAAC,IAAI,CAAI,GAAA,EAAK,EAAA,GAAG,QAAQ,CAAA,CAAE,OAAO,CAAO,GAAA,KAAA;AAC3E,IAAA,OAAOC,uBAAG,cAAe,CAAAC,YAAA,CAAY,GAAI,CAAA,GAAA,EAAK,WAAW,CAAC,CAAA,CAAA;AAAA,GAC3D,CAAA,CAAA;AAED,EAAO,OAAA,eAAA,CAAgB,IAAI,CAAQ,GAAA,MAAA;AAAA,IACjC,IAAA,EAAM,IAAI,WAAY,CAAA,IAAA;AAAA,IACtB,OAAS,EAAAA,YAAA,CAAY,GAAI,CAAA,GAAA,EAAK,WAAW,CAAA;AAAA,IACzC,GAAK,EAAA;AAAA,MACH,OAAS,EAAA,QAAA;AAAA,KACX;AAAA,GACA,CAAA,CAAA,CAAA;AACJ;;ACjBO,SAAS,mBAA4B,GAAA;AAC1C,EAAAC,SAAA,CAAK,UAAW,CAAA,OAAO,EAAE,IAAA,EAAW,KAAA;AAClC,IAAK,IAAA,CAAA,EAAA,CAAG,aAAa,CAAS,KAAA,KAAA;AAC5B,MAAA,MAAM,IAAI,KAAA,CAAM,CAA+B,4BAAA,EAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AAAA,KACvD,CAAA,CAAA;AAED,IAAK,IAAA,CAAA,EAAA,CAAG,WAAW,CAAO,GAAA,KAAA;AACxB,MAAI,IAAA,GAAA,CAAI,IAAK,EAAA,KAAM,OAAS,EAAA;AAC1B,QAAA,MAAM,IAAI,KAAM,CAAA,CAAA,kCAAA,EAAqC,GAAI,CAAA,IAAA,EAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,OACpE;AAAA,KACD,CAAA,CAAA;AAAA,GACF,CAAA,CAAA;AACH;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PlaywrightTestConfig } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generates a list of playwright projects by scanning the monorepo for packages with an `e2e-tests/` folder.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare function generateProjects(): PlaywrightTestConfig['projects'];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Calling this at the top of your test file will ensure that tests fail if the browser
|
|
12
|
+
* logs any errors or if there are any uncaught exceptions.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
declare function failOnBrowserErrors(): void;
|
|
17
|
+
|
|
18
|
+
export { failOnBrowserErrors, generateProjects };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage/e2e-test-utils",
|
|
3
|
+
"description": "Shared end-to-end test utilities Backstage",
|
|
4
|
+
"version": "0.1.0-next.0",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./playwright": {
|
|
13
|
+
"require": "./dist/playwright.cjs.js",
|
|
14
|
+
"types": "./dist/playwright.d.ts",
|
|
15
|
+
"default": "./dist/playwright.cjs.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"backstage": {
|
|
20
|
+
"role": "node-library"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"start": "backstage-cli package start",
|
|
24
|
+
"build": "backstage-cli package build",
|
|
25
|
+
"lint": "backstage-cli package lint",
|
|
26
|
+
"test": "backstage-cli package test",
|
|
27
|
+
"clean": "backstage-cli package clean",
|
|
28
|
+
"prepack": "backstage-cli package prepack",
|
|
29
|
+
"postpack": "backstage-cli package postpack"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@manypkg/get-packages": "^1.1.3",
|
|
33
|
+
"fs-extra": "^10.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@backstage/cli": "^0.23.0-next.0",
|
|
37
|
+
"@backstage/cli-node": "^0.1.5-next.0",
|
|
38
|
+
"@types/fs-extra": "^9.0.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@playwright/test": "^1.32.3"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@playwright/test": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"playwright"
|
|
51
|
+
]
|
|
52
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 The Backstage Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|