Skip to content

Commit 7385671

Browse files
committed
{fix} properly fail builder if tests fail
Fixes #21
1 parent db66f7f commit 7385671

File tree

9 files changed

+57
-9
lines changed

9 files changed

+57
-9
lines changed

.github/workflows/validation-workflow.yml

+10
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,13 @@ jobs:
101101
shell: bash
102102
run: |
103103
yarn ${{matrix.cli}} test integration --configuration production
104+
105+
- name: "Failing tests"
106+
shell: bash
107+
run: |
108+
set +e
109+
yarn ${{matrix.cli}} test integration --configuration failing
110+
if [ $? -eq 0 ]; then
111+
echo "Expected command to fail"
112+
exit 1
113+
fi

.yarn/versions/83adbf9a.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
releases:
2+
"@ngx-playwright/test": patch

angular.json

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
},
9393
"production": {
9494
"devServerTarget": ":serve:production"
95+
},
96+
"failing": {
97+
"baseUrl": "http://localhost:65535",
98+
"config": "integration/playwright-test-failure.e2e-config.js"
9599
}
96100
}
97101
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {test, expect} from "@ngx-playwright/test";
2+
3+
test("fails", () => {
4+
expect(true).toBe(false);
5+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @ts-check
2+
// cspell:ignore lcovonly lcov
3+
4+
import {join, dirname} from "path";
5+
import {fileURLToPath} from "url";
6+
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
9+
/**
10+
* @type {import('../packages/test/src/index.js').PlaywrightTestConfig}
11+
*/
12+
const config = {
13+
use: {
14+
channel: "chrome",
15+
headless: true,
16+
},
17+
18+
testDir: join(__dirname, "e2e/failing-specs"),
19+
testMatch: "**/*.e2e-spec.js",
20+
21+
reporter: process.env.CI ? "github" : "list",
22+
};
23+
24+
export default config;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/cli": "^18.2.0",
1515
"@nrwl/linter": "^12.8.0",
1616
"@snuggery/build-node": "0.11.0",
17-
"@snuggery/snuggery": "0.13.0",
17+
"@snuggery/snuggery": "0.13.1",
1818
"@snuggery/yarn": "0.7.1",
1919
"@typescript-eslint/eslint-plugin": "^6.14.0",
2020
"@typescript-eslint/parser": "^6.14.0",

packages/test/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@playwright/test": "^1.20.2",
4949
"@snuggery/architect": "^0.11.0",
5050
"@snuggery/schematics": "^0.11.0",
51-
"@snuggery/snuggery": "^0.13.0",
51+
"@snuggery/snuggery": "^0.13.1",
5252
"composed-dom": "^1.1.0"
5353
},
5454
"devDependencies": {

packages/test/src/builder/builder.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export async function execute(input, context) {
101101
const {baseUrl, stop} = await getBaseUrl(input, context);
102102

103103
try {
104-
await firstValueFrom(
104+
const result = await firstValueFrom(
105105
context,
106106
scheduleTarget(
107107
{
@@ -161,6 +161,9 @@ export async function execute(input, context) {
161161
context,
162162
),
163163
);
164+
165+
// Only pass the status through, playwright will already have printed information on the failure
166+
return {success: result.success};
164167
} finally {
165168
await stop();
166169
}

yarn.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ __metadata:
19751975
"@playwright/test": "npm:^1.20.2"
19761976
"@snuggery/architect": "npm:^0.11.0"
19771977
"@snuggery/schematics": "npm:^0.11.0"
1978-
"@snuggery/snuggery": "npm:^0.13.0"
1978+
"@snuggery/snuggery": "npm:^0.13.1"
19791979
"@types/node": "npm:^20.12.12"
19801980
composed-dom: "npm:^1.1.0"
19811981
rxjs: "npm:7.8.0"
@@ -2497,9 +2497,9 @@ __metadata:
24972497
languageName: node
24982498
linkType: hard
24992499

2500-
"@snuggery/snuggery@npm:0.13.0, @snuggery/snuggery@npm:^0.13.0":
2501-
version: 0.13.0
2502-
resolution: "@snuggery/snuggery@npm:0.13.0"
2500+
"@snuggery/snuggery@npm:0.13.1, @snuggery/snuggery@npm:^0.13.1":
2501+
version: 0.13.1
2502+
resolution: "@snuggery/snuggery@npm:0.13.1"
25032503
dependencies:
25042504
"@angular-devkit/architect": "npm:>= 0.1800.0 < 0.1900.0"
25052505
"@angular-devkit/core": "npm:^18.0.0"
@@ -2519,7 +2519,7 @@ __metadata:
25192519
typanion: "npm:^3.12.1"
25202520
bin:
25212521
sn: bin.js
2522-
checksum: 6592009cf5191ceb48333d68df5fa0c5acfcfc4637ab435522ac13c60e47f10768365c7a5a0e36819118846a5e19441137c6cc4e120a7162be415d7d2a49b2c5
2522+
checksum: cdc5d1988613efbc2b40aa3ccc2e5f48a0b656dab42d66c385455f11831ca56b0f2ad92bdaabc7efbb661b2f7a8b852dff1301fb19e235e3878d6385db8c7eb1
25232523
languageName: node
25242524
linkType: hard
25252525

@@ -7342,7 +7342,7 @@ __metadata:
73427342
"@angular/cli": "npm:^18.2.0"
73437343
"@nrwl/linter": "npm:^12.8.0"
73447344
"@snuggery/build-node": "npm:0.11.0"
7345-
"@snuggery/snuggery": "npm:0.13.0"
7345+
"@snuggery/snuggery": "npm:0.13.1"
73467346
"@snuggery/yarn": "npm:0.7.1"
73477347
"@typescript-eslint/eslint-plugin": "npm:^6.14.0"
73487348
"@typescript-eslint/parser": "npm:^6.14.0"

0 commit comments

Comments
 (0)