@toptal/davinci-qa 5.0.2-alpha-tph-1237-github-test-results.1303 → 5.0.2-alpha-tph-1237-github-test-results.1304
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/README.md
CHANGED
|
@@ -17,6 +17,8 @@ To run jest tests with your config file just go to the root directory of your pr
|
|
|
17
17
|
Options:
|
|
18
18
|
|
|
19
19
|
- `--setupFilesAfterEnv` - a list of paths to global configuration files for jest tests
|
|
20
|
+
- `--inspect` - start test run in inspect mode, allowing the dev tools to be attached to the test runner process. Read more at [Profiling Unit Tests](https://toptal-core.atlassian.net/wiki/spaces/FE/pages/1446379739/Profiling+Unit+Tests).
|
|
21
|
+
- `--tag <project-tag>` - the project name matching [Anvil's expected tag](https://github.com/toptal/anvil/blob/2ea49649db605fc06492fcf346bdb0c56fff0769/app/models/test_result.rb#L10). Used to generate Anvil Reports.
|
|
20
22
|
- Any other jest option (ex. `--runInBand`)
|
|
21
23
|
|
|
22
24
|
[Jest CLI docs](https://jestjs.io/docs/en/cli)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/davinci-qa",
|
|
3
|
-
"version": "5.0.2-alpha-tph-1237-github-test-results.
|
|
3
|
+
"version": "5.0.2-alpha-tph-1237-github-test-results.1304+6d6284a",
|
|
4
4
|
"description": "QA package to test your application",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@cypress/webpack-preprocessor": "^5.7.0",
|
|
37
37
|
"@testing-library/jest-dom": "^5.14.1",
|
|
38
38
|
"@testing-library/react": "^12.0.0",
|
|
39
|
-
"@toptal/davinci-cli-shared": "1.4.2-alpha-tph-1237-github-test-results.
|
|
39
|
+
"@toptal/davinci-cli-shared": "1.4.2-alpha-tph-1237-github-test-results.1304+6d6284a",
|
|
40
40
|
"@types/jest": "^26.0.15",
|
|
41
41
|
"babel-jest": "^26.3.0",
|
|
42
42
|
"cypress": "^8.6.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"matchmedia-polyfill": "^0.3.2",
|
|
51
51
|
"semver": "^7.3.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "6d6284a28181286e0dab3ed19369710f62a8b7eb"
|
|
54
54
|
}
|
|
@@ -7,7 +7,7 @@ const styledComponentsVersionCheck = require('../utils/styled-components-version
|
|
|
7
7
|
const toJestCLIArguments = require('../utils/to-jest-cli-arguments')
|
|
8
8
|
const getAbsolutePath = relativePath => path.join(__dirname, relativePath)
|
|
9
9
|
|
|
10
|
-
const defaultCIJestReporters = [
|
|
10
|
+
const defaultCIJestReporters = (tag) => [
|
|
11
11
|
[
|
|
12
12
|
'jest-silent-reporter', {
|
|
13
13
|
'useDots': true,
|
|
@@ -24,11 +24,15 @@ const defaultCIJestReporters = [
|
|
|
24
24
|
'publicPath': './reports',
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
|
-
|
|
27
|
+
[
|
|
28
|
+
getAbsolutePath('../reporters/jest-anvil-reporter.js'), {
|
|
29
|
+
'tag': tag
|
|
30
|
+
}
|
|
31
|
+
]
|
|
28
32
|
]
|
|
29
33
|
|
|
30
34
|
const unitTestsCommand = ({
|
|
31
|
-
options: { inspect = false, ...jestOptions } = {},
|
|
35
|
+
options: { inspect = false, tag, ...jestOptions } = {},
|
|
32
36
|
files: testPathPattern = []
|
|
33
37
|
}) => {
|
|
34
38
|
print.green('Running unit tests...')
|
|
@@ -69,7 +73,7 @@ const unitTestsCommand = ({
|
|
|
69
73
|
defaultOptions.reporters = jestOptions.reporters
|
|
70
74
|
} else {
|
|
71
75
|
defaultOptions.testLocationInResults = true // allows reporters to return test line number
|
|
72
|
-
defaultOptions.reporters = defaultCIJestReporters
|
|
76
|
+
defaultOptions.reporters = defaultCIJestReporters(tag)
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
@@ -102,7 +106,12 @@ const unitTestsCommandCreator = {
|
|
|
102
106
|
},
|
|
103
107
|
{
|
|
104
108
|
label:
|
|
105
|
-
|
|
109
|
+
'the project name matching Anvil\'s expected tag. Used to generate Anvil-compatible test reports.',
|
|
110
|
+
name: '--tag <tag>'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label:
|
|
114
|
+
'start the test run in inspect mode, allowing dev tools to be attached to the test runner process. Read more at https://toptal-core.atlassian.net/wiki/spaces/FE/pages/1446379739/Profiling+Unit+Tests.',
|
|
106
115
|
name: '--inspect'
|
|
107
116
|
}
|
|
108
117
|
]
|
|
@@ -17,7 +17,7 @@ class JestAnvilReporter {
|
|
|
17
17
|
return fileTestResult.testResults.map(res => ({ ...res, fileName }))
|
|
18
18
|
})
|
|
19
19
|
const anvilTestResults = individualTestResults.map(testResult => {
|
|
20
|
-
|
|
20
|
+
const results = {
|
|
21
21
|
file_name: testResult.fileName,
|
|
22
22
|
line_number: testResult.location.line,
|
|
23
23
|
status: testResult.status,
|
|
@@ -26,8 +26,11 @@ class JestAnvilReporter {
|
|
|
26
26
|
description: testResult.title,
|
|
27
27
|
error: testResult.failureDetails.length > 0 ? testResult.failureDetails[0].message : null,
|
|
28
28
|
backtrace: testResult.failureDetails.length > 0 ? testResult.failureDetails[0].stack : null,
|
|
29
|
-
tag: 'platform', // TODO - change it so projects can modify it
|
|
30
29
|
}
|
|
30
|
+
if (this._options.tag) {
|
|
31
|
+
results['tag'] = this._options.tag
|
|
32
|
+
}
|
|
33
|
+
return results
|
|
31
34
|
})
|
|
32
35
|
const anvilPayload = {
|
|
33
36
|
"test_results": [
|