-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* dynamically collect test results in global var * improve testFnWrapper for Jasmine * create error message for 'after-hook' variable * fix * Update packages/wdio-utils/src/test-framework/testFnWrapper.ts * Update packages/wdio-utils/src/test-framework/testFnWrapper.ts * Update packages/wdio-utils/src/test-framework/testFnWrapper.ts * add files with expected results * add tests * add config and write test results to files in afterTest() * fix: assign test results to 'result' to avoid 'undefined' * add smoke test and optimize assertions counting dynamic values * fix --------- Co-authored-by: Christian Bromann <git@bromann.dev>
- Loading branch information
1 parent
1782885
commit 17c74bd
Showing
8 changed files
with
239 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,4 +115,4 @@ export const HOOK_DEFINITION = { | |
throw new Error('expected hook to be type of function') | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/helpers/jasmine-after-hook-validation/expected-results/expectedTestFailed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"test": { | ||
"id": "spec1", | ||
"description": "should failed", | ||
"fullName": "Jasmine afterTest() hook validation should failed", | ||
"parentSuiteId": "suite1", | ||
"failedExpectations": [ | ||
{ | ||
"matcherName": "toBe", | ||
"message": "Expected false to be true.", | ||
"passed": false, | ||
"expected": true, | ||
"actual": false | ||
} | ||
], | ||
"passedExpectations": [], | ||
"deprecationWarnings": [], | ||
"pendingReason": "", | ||
"duration": null, | ||
"properties": null, | ||
"debugLogs": null | ||
}, | ||
"context": { | ||
"wdioRetries": 0 | ||
}, | ||
"error": { | ||
"matcherName": "toBe", | ||
"message": "Expected false to be true.", | ||
"passed": false, | ||
"expected": true, | ||
"actual": false | ||
}, | ||
"result": { | ||
"id": "spec1", | ||
"description": "should failed", | ||
"fullName": "Jasmine afterTest() hook validation should failed", | ||
"parentSuiteId": "suite1", | ||
"failedExpectations": [ | ||
{ | ||
"matcherName": "toBe", | ||
"message": "Expected false to be true.", | ||
"passed": false, | ||
"expected": true, | ||
"actual": false | ||
} | ||
], | ||
"passedExpectations": [], | ||
"deprecationWarnings": [], | ||
"pendingReason": "", | ||
"duration": null, | ||
"properties": null, | ||
"debugLogs": null | ||
}, | ||
"passed": false, | ||
"retries": { | ||
"attempts": 0, | ||
"limit": 0 | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/helpers/jasmine-after-hook-validation/expected-results/expectedTestPassed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"test": { | ||
"id": "spec0", | ||
"description": "should pass", | ||
"fullName": "Jasmine afterTest() hook validation should pass", | ||
"parentSuiteId": "suite1", | ||
"failedExpectations": [], | ||
"passedExpectations": [ | ||
{ | ||
"matcherName": "toBe", | ||
"message": "Passed.", | ||
"stack": "", | ||
"passed": true | ||
} | ||
], | ||
"deprecationWarnings": [], | ||
"pendingReason": "", | ||
"duration": null, | ||
"properties": null, | ||
"debugLogs": null | ||
}, | ||
"context": { | ||
"wdioRetries": 0 | ||
}, | ||
"result": { | ||
"id": "spec0", | ||
"description": "should pass", | ||
"fullName": "Jasmine afterTest() hook validation should pass", | ||
"parentSuiteId": "suite1", | ||
"failedExpectations": [], | ||
"passedExpectations": [ | ||
{ | ||
"matcherName": "toBe", | ||
"message": "Passed.", | ||
"stack": "", | ||
"passed": true | ||
} | ||
], | ||
"deprecationWarnings": [], | ||
"pendingReason": "", | ||
"duration": null, | ||
"properties": null, | ||
"debugLogs": null | ||
}, | ||
"passed": true, | ||
"retries": { | ||
"attempts": 0, | ||
"limit": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import path from 'node:path' | ||
import url from 'node:url' | ||
import fs from 'node:fs/promises' | ||
|
||
import { config as baseConfig } from './config.js' | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) | ||
|
||
export const config = { | ||
...baseConfig, | ||
reporters: [ | ||
['spec', { | ||
addConsoleLogs: true | ||
}] | ||
], | ||
framework: 'jasmine', | ||
jasmineOpts: { | ||
...baseConfig.jasmineOpts, | ||
}, | ||
afterTest: async function ( | ||
test, | ||
context, | ||
{ error, result, duration, passed, retries } | ||
) { | ||
const actualTestResult = { | ||
test: test, | ||
context: context, | ||
error: error, | ||
result: result, | ||
duration: duration, | ||
passed: passed, | ||
retries: retries | ||
} | ||
|
||
if (test.description.includes('pass')) { | ||
fs.writeFile(path.resolve(__dirname, 'actualResultsPassed.log'), JSON.stringify(actualTestResult)) | ||
} else { | ||
fs.writeFile(path.resolve(__dirname, 'actualResultsFailed.log'), JSON.stringify(actualTestResult)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
describe('Jasmine afterTest() hook validation', () => { | ||
it('should pass', () => { | ||
expect(true).toBe(true) | ||
}) | ||
|
||
it('should failed', () => { | ||
expect(false).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters