@toptal/davinci-qa 5.0.2-alpha-fx-2156-improve-build-performance.1301 → 5.0.2-alpha-tph-1237-github-test-results.1303

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-qa",
3
- "version": "5.0.2-alpha-fx-2156-improve-build-performance.1301+179cd15",
3
+ "version": "5.0.2-alpha-tph-1237-github-test-results.1303+83f0909",
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-fx-2156-improve-build-performance.1301+179cd15",
39
+ "@toptal/davinci-cli-shared": "1.4.2-alpha-tph-1237-github-test-results.1303+83f0909",
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": "179cd15c69c4b54712d32804d45d18a2f09d06f0"
53
+ "gitHead": "83f0909885f1d5287d40df378e2a6c7127484437"
54
54
  }
@@ -1,9 +1,11 @@
1
1
  const { print, files } = require('@toptal/davinci-cli-shared')
2
2
  const jest = require('jest')
3
+ const path = require('path')
3
4
 
4
5
  const excludedFilesFromCoverage = require('../configs/excludeFilesFromCoverage')
5
6
  const styledComponentsVersionCheck = require('../utils/styled-components-version-check')
6
7
  const toJestCLIArguments = require('../utils/to-jest-cli-arguments')
8
+ const getAbsolutePath = relativePath => path.join(__dirname, relativePath)
7
9
 
8
10
  const defaultCIJestReporters = [
9
11
  [
@@ -21,7 +23,8 @@ const defaultCIJestReporters = [
21
23
  'jest-html-reporters', {
22
24
  'publicPath': './reports',
23
25
  }
24
- ]
26
+ ],
27
+ getAbsolutePath('../reporters/jest-anvil-reporter.js')
25
28
  ]
26
29
 
27
30
  const unitTestsCommand = ({
@@ -62,9 +65,12 @@ const unitTestsCommand = ({
62
65
 
63
66
  // to show smaller log of tests running on CI
64
67
  // and a nicer html report
65
- defaultOptions.reporters = jestOptions.reporters
66
- ? jestOptions.reporters
67
- : defaultCIJestReporters
68
+ if (jestOptions.reporters) {
69
+ defaultOptions.reporters = jestOptions.reporters
70
+ } else {
71
+ defaultOptions.testLocationInResults = true // allows reporters to return test line number
72
+ defaultOptions.reporters = defaultCIJestReporters
73
+ }
68
74
  }
69
75
 
70
76
  const options = {
@@ -0,0 +1,47 @@
1
+ const { print } = require('@toptal/davinci-cli-shared')
2
+ const fs = require('fs')
3
+
4
+ class JestAnvilReporter {
5
+ constructor(globalConfig, options) {
6
+ this._globalConfig = globalConfig
7
+ this._options = options
8
+ }
9
+
10
+ onRunComplete(contexts, results) {
11
+ print.grey('Starting Anvil processing...')
12
+ console.time('Anvil reporter run')
13
+ const fileTestResults = results.testResults
14
+ const runPath = process.cwd()
15
+ const individualTestResults = fileTestResults.flatMap(fileTestResult => {
16
+ const fileName = fileTestResult.testFilePath.replace(runPath, '.')
17
+ return fileTestResult.testResults.map(res => ({ ...res, fileName }))
18
+ })
19
+ const anvilTestResults = individualTestResults.map(testResult => {
20
+ return {
21
+ file_name: testResult.fileName,
22
+ line_number: testResult.location.line,
23
+ status: testResult.status,
24
+ duration: testResult.duration,
25
+ scenario_name: testResult.ancestorTitles.concat(testResult.title).join('/'),
26
+ description: testResult.title,
27
+ error: testResult.failureDetails.length > 0 ? testResult.failureDetails[0].message : null,
28
+ backtrace: testResult.failureDetails.length > 0 ? testResult.failureDetails[0].stack : null,
29
+ tag: 'platform', // TODO - change it so projects can modify it
30
+ }
31
+ })
32
+ const anvilPayload = {
33
+ "test_results": [
34
+ anvilTestResults
35
+ ]
36
+ }
37
+ fs.writeFileSync('./anvil_test_results.json', JSON.stringify(anvilPayload, undefined, 2), err => {
38
+ if (err) {
39
+ print.red('Failed to create anvil test results', err)
40
+ throw err
41
+ }
42
+ })
43
+ console.timeEnd('Anvil reporter run')
44
+ }
45
+ }
46
+
47
+ module.exports = JestAnvilReporter
@@ -0,0 +1,111 @@
1
+ SUCCESS = {
2
+ numFailedTestSuites: 0,
3
+ numFailedTests: 0,
4
+ numPassedTestSuites: 3,
5
+ numPassedTests: 13,
6
+ numPendingTestSuites: 0,
7
+ numPendingTests: 0,
8
+ numRuntimeErrorTestSuites: 0,
9
+ numTodoTests: 0,
10
+ numTotalTestSuites: 3,
11
+ numTotalTests: 13,
12
+ openHandles: [
13
+ ],
14
+ snapshot: {
15
+ added: 0,
16
+ didUpdate: false,
17
+ failure: false,
18
+ filesAdded: 0,
19
+ filesRemoved: 0,
20
+ filesRemovedList: [
21
+ ],
22
+ filesUnmatched: 0,
23
+ filesUpdated: 0,
24
+ matched: 0,
25
+ total: 0,
26
+ unchecked: 0,
27
+ uncheckedKeysByFile: [
28
+ ],
29
+ unmatched: 0,
30
+ updated: 0,
31
+ },
32
+ startTime: 1635357418106,
33
+ success: false,
34
+ testResults: [
35
+ {
36
+ leaks: false,
37
+ numFailingTests: 0,
38
+ numPassingTests: 6,
39
+ numPendingTests: 0,
40
+ numTodoTests: 0,
41
+ openHandles: [
42
+ ],
43
+ perfStats: {
44
+ end: 1635357420742,
45
+ runtime: 1193,
46
+ slow: false,
47
+ start: 1635357419549,
48
+ },
49
+ skipped: false,
50
+ snapshot: {
51
+ added: 0,
52
+ fileDeleted: false,
53
+ matched: 0,
54
+ unchecked: 0,
55
+ unmatched: 0,
56
+ updated: 0,
57
+ uncheckedKeys: [
58
+ ],
59
+ },
60
+ testFilePath: "./packages/qa/src/utils/styled-components-version-check.test.js",
61
+ testResults: [
62
+ {
63
+ ancestorTitles: [
64
+ "styled-components version check",
65
+ "has wrong (^4.4.1) SC version in dependencies",
66
+ ],
67
+ duration: 7,
68
+ failureDetails: [
69
+ ],
70
+ failureMessages: [
71
+ ],
72
+ fullName: "styled-components version check has wrong (^4.4.1) SC version in dependencies should throw an error",
73
+ location: {
74
+ column: 4,
75
+ line: 44,
76
+ },
77
+ numPassingAsserts: 0,
78
+ status: "passed",
79
+ title: "should throw an error",
80
+ },
81
+ {
82
+ ancestorTitles: [
83
+ "styled-components version check",
84
+ "has correct (^5.0.1) SC version in dependencies",
85
+ ],
86
+ duration: 1,
87
+ failureDetails: [
88
+ ],
89
+ failureMessages: [
90
+ ],
91
+ fullName: "styled-components version check has correct (^5.0.1) SC version in dependencies should NOT throw an error",
92
+ location: {
93
+ column: 4,
94
+ line: 50,
95
+ },
96
+ numPassingAsserts: 0,
97
+ status: "passed",
98
+ title: "should NOT throw an error",
99
+ },
100
+ ],
101
+ console: undefined,
102
+ failureMessage: null,
103
+ displayName: undefined,
104
+ sourceMaps: undefined,
105
+ coverage: undefined,
106
+ }
107
+ ],
108
+ wasInterrupted: false,
109
+ }
110
+
111
+ module.exports = SUCCESS