@spscommerce/e2e-core 1.1.2 → 1.1.3

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.
@@ -33,7 +33,7 @@ class JestEnvironmentFailFast extends ParentEnvironment {
33
33
  // https://github.com/facebook/jest/blob/main/packages/jest-circus/src/eventHandler.ts
34
34
  async handleTestEvent(event, state) {
35
35
  await super.handleTestEvent(event);
36
-
36
+
37
37
  // TEST STARTED
38
38
  // Delete already existing screenshot/trace file before test starts if it ran twice due to jest.retryTimes()
39
39
  if (event.name === 'test_start') {
@@ -47,8 +47,17 @@ class JestEnvironmentFailFast extends ParentEnvironment {
47
47
  }
48
48
  }
49
49
 
50
- // TEST FAILED
51
- // Take a screenshot for each failed test while running in CI
50
+ // HOOK FAILS
51
+ // Take a screenshot for each failed test
52
+ if (event.name === 'hook_failure') {
53
+ await this.global.page.screenshot({
54
+ fullPage: true,
55
+ path: process.cwd() + `/results-e2e/screenshots/${event.hook.parent.name.replace(/_$/, '')}.png`,
56
+ });
57
+ }
58
+
59
+ // TEST FAILS
60
+ // Take a screenshot for each failed test
52
61
  if (event.name === 'test_fn_failure' && !event.test.parent.name.includes('visual')) {
53
62
  this.failedTest = true;
54
63
  this.failedTestName = event.test.name;
@@ -71,14 +80,13 @@ class JestEnvironmentFailFast extends ParentEnvironment {
71
80
 
72
81
  // TEST FINISHED AND VIDEO OPTION IS SET TO TRUE
73
82
  // Save test status, test suite name and random PW video name
74
- if (event.name === "test_done" && process.env.VIDEO) {
83
+ if (event.name === "test_done" && process.env.VIDEO && (process.env.VIDEO.toLowerCase() === 'true')) {
75
84
  const success = event.test.errors.length === 0 ? true : false;
76
85
  const testSuiteName = event.test.parent.name;
77
86
  const videoName = await this.global.page.video().path();
78
87
  this.videos.push({ testSuiteName, videoName, success });
79
88
  }
80
89
 
81
-
82
90
  // TEST FINISHES AND FAILS
83
91
  // Skip all further tests in the suite (all tests are related to each other) if
84
92
  // - any test is failed AND suite name includes 'FailFast'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spscommerce/e2e-core",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "An automation test framework which is based on playwright, jest and ts",
5
5
  "scripts": {
6
6
  "test": "jest",