@toptal/davinci-qa 5.0.2-alpha-tph-1237-github-test-results.1303 → 5.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1019](https://github.com/toptal/davinci/pull/1019) [`2f922ec4`](https://github.com/toptal/davinci/commit/2f922ec4c287ac6097cb1026db95359776f8010b) Thanks [@rafael-anachoreta](https://github.com/rafael-anachoreta)! - Add Anvil reporter to Jest
8
+
3
9
  ## 5.0.1
4
10
 
5
11
  ### Patch Changes
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
+ - `--anvilTag <anvil-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)
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@toptal/davinci-qa",
3
+ "version": "5.1.0",
4
+ "description": "QA package to test your application",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "keywords": [
9
+ "qa",
10
+ "testing"
11
+ ],
12
+ "author": "Toptal",
13
+ "homepage": "https://github.com/toptal/davinci/tree/master/packages/qa#readme",
14
+ "license": "ISC",
15
+ "bin": {
16
+ "davinci-qa": "./bin/davinci-qa.js"
17
+ },
18
+ "main": "./src/index.js",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/toptal/davinci.git"
22
+ },
23
+ "scripts": {
24
+ "build:package": "../../bin/build-package.js",
25
+ "prepublishOnly": "../../bin/prepublish.js",
26
+ "test": "echo \"Error: run tests from root\" && exit 1"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/toptal/davinci/issues"
30
+ },
31
+ "dependencies": {
32
+ "@babel/core": "^7.14.8",
33
+ "@babel/preset-env": "^7.11.5",
34
+ "@babel/preset-react": "^7.10.4",
35
+ "@babel/preset-typescript": "^7.10.4",
36
+ "@cypress/webpack-preprocessor": "^5.7.0",
37
+ "@testing-library/jest-dom": "^5.14.1",
38
+ "@testing-library/react": "^12.0.0",
39
+ "@toptal/davinci-cli-shared": "^1.3.4",
40
+ "@types/jest": "^26.0.15",
41
+ "babel-jest": "^26.3.0",
42
+ "cypress": "^8.6.0",
43
+ "fs-extra": "^10.0.0",
44
+ "jest": "^26.6.3",
45
+ "jest-html-reporters": "^2.1.6",
46
+ "jest-junit": "^13.0.0",
47
+ "jest-silent-reporter": "^0.5.0",
48
+ "jest-styled-components": "^7.0.3",
49
+ "jsdom": "^16.5.2",
50
+ "matchmedia-polyfill": "^0.3.2",
51
+ "semver": "^7.3.2"
52
+ }
53
+ }
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.1303+83f0909",
3
+ "version": "5.1.0",
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.1303+83f0909",
39
+ "@toptal/davinci-cli-shared": "^1.3.4",
40
40
  "@types/jest": "^26.0.15",
41
41
  "babel-jest": "^26.3.0",
42
42
  "cypress": "^8.6.0",
@@ -49,6 +49,5 @@
49
49
  "jsdom": "^16.5.2",
50
50
  "matchmedia-polyfill": "^0.3.2",
51
51
  "semver": "^7.3.2"
52
- },
53
- "gitHead": "83f0909885f1d5287d40df378e2a6c7127484437"
52
+ }
54
53
  }
@@ -0,0 +1,65 @@
1
+ const convertToCLIParametersMock = jest.fn()
2
+ const getPackageFilePathMock = jest.fn()
3
+
4
+ jest.mock('@toptal/davinci-cli-shared', () => ({
5
+ runSync: jest.fn(),
6
+ print: {
7
+ green: jest.fn()
8
+ },
9
+ convertToCLIParameters: convertToCLIParametersMock,
10
+ files: {
11
+ getPackageFilePath: getPackageFilePathMock
12
+ }
13
+ }))
14
+
15
+ const { runSync } = require('@toptal/davinci-cli-shared')
16
+
17
+ const { action } = require('./end-to-end-tests')
18
+
19
+ describe('endToEndTestCommand', () => {
20
+ it('runs cypress with default options', () => {
21
+ convertToCLIParametersMock.mockReturnValueOnce([])
22
+ getPackageFilePathMock.mockReturnValueOnce('packages/qa/src/configs/cypress.config.json')
23
+
24
+ action({ options: {} })
25
+
26
+ expect(runSync).toHaveBeenCalledWith('npx', [
27
+ 'cypress',
28
+ 'run',
29
+ '--config-file',
30
+ 'packages/qa/src/configs/cypress.config.json'
31
+ ])
32
+
33
+ expect(convertToCLIParametersMock).toHaveBeenCalledWith({})
34
+ expect(getPackageFilePathMock).toHaveBeenCalledWith(
35
+ '@toptal/davinci-qa',
36
+ 'src/configs/cypress.config.json'
37
+ )
38
+ })
39
+
40
+ it('runs cypress with custom options', () => {
41
+ const spec = 'cypress/integration/activation_flow.spec.ts'
42
+
43
+ convertToCLIParametersMock.mockReturnValueOnce(['--spec', spec])
44
+ getPackageFilePathMock.mockReturnValueOnce('packages/qa/src/configs/cypress.config.json')
45
+
46
+ action({ options: { spec } })
47
+
48
+ expect(runSync).toHaveBeenCalledWith('npx', [
49
+ 'cypress',
50
+ 'run',
51
+ '--config-file',
52
+ 'packages/qa/src/configs/cypress.config.json',
53
+ '--spec',
54
+ spec
55
+ ])
56
+
57
+ expect(convertToCLIParametersMock).toHaveBeenCalledWith({
58
+ spec
59
+ })
60
+ expect(getPackageFilePathMock).toHaveBeenCalledWith(
61
+ '@toptal/davinci-qa',
62
+ 'src/configs/cypress.config.json'
63
+ )
64
+ })
65
+ })
@@ -5,9 +5,9 @@ const path = require('path')
5
5
  const excludedFilesFromCoverage = require('../configs/excludeFilesFromCoverage')
6
6
  const styledComponentsVersionCheck = require('../utils/styled-components-version-check')
7
7
  const toJestCLIArguments = require('../utils/to-jest-cli-arguments')
8
- const getAbsolutePath = relativePath => path.join(__dirname, relativePath)
8
+ const getRootProjectPath = relativePath => path.join(__dirname, relativePath)
9
9
 
10
- const defaultCIJestReporters = [
10
+ const defaultCIJestReporters = anvilTag => [
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
- getAbsolutePath('../reporters/jest-anvil-reporter.js')
27
+ [
28
+ getRootProjectPath('../reporters/jest-anvil-reporter.js'), {
29
+ 'anvilTag': anvilTag
30
+ }
31
+ ]
28
32
  ]
29
33
 
30
34
  const unitTestsCommand = ({
31
- options: { inspect = false, ...jestOptions } = {},
35
+ options: { inspect = false, anvilTag, ...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(anvilTag)
73
77
  }
74
78
  }
75
79
 
@@ -102,7 +106,12 @@ const unitTestsCommandCreator = {
102
106
  },
103
107
  {
104
108
  label:
105
- 'Start in the 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.',
109
+ 'the project name matching Anvil\'s expected tag. Used to generate Anvil-compatible test reports.',
110
+ name: '--anvilTag <anvilTag>'
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
  ]
@@ -8,7 +8,7 @@ class JestAnvilReporter {
8
8
  }
9
9
 
10
10
  onRunComplete(contexts, results) {
11
- print.grey('Starting Anvil processing...')
11
+ print.grey('Starting Anvil reporter processing...')
12
12
  console.time('Anvil reporter run')
13
13
  const fileTestResults = results.testResults
14
14
  const runPath = process.cwd()
@@ -17,17 +17,21 @@ class JestAnvilReporter {
17
17
  return fileTestResult.testResults.map(res => ({ ...res, fileName }))
18
18
  })
19
19
  const anvilTestResults = individualTestResults.map(testResult => {
20
- return {
20
+ const anvilResults = {
21
21
  file_name: testResult.fileName,
22
- line_number: testResult.location.line,
22
+ line_number: testResult.location && testResult.location.line,
23
23
  status: testResult.status,
24
24
  duration: testResult.duration,
25
25
  scenario_name: testResult.ancestorTitles.concat(testResult.title).join('/'),
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
29
+ test_type: 'unit'
30
30
  }
31
+ if (this._options && this._options.anvilTag) {
32
+ anvilResults['tag'] = this._options.anvilTag
33
+ }
34
+ return anvilResults
31
35
  })
32
36
  const anvilPayload = {
33
37
  "test_results": [
@@ -36,7 +40,7 @@ class JestAnvilReporter {
36
40
  }
37
41
  fs.writeFileSync('./anvil_test_results.json', JSON.stringify(anvilPayload, undefined, 2), err => {
38
42
  if (err) {
39
- print.red('Failed to create anvil test results', err)
43
+ print.red('Failed to create Anvil test results', err)
40
44
  throw err
41
45
  }
42
46
  })
@@ -44,4 +48,4 @@ class JestAnvilReporter {
44
48
  }
45
49
  }
46
50
 
47
- module.exports = JestAnvilReporter
51
+ module.exports = JestAnvilReporter
@@ -0,0 +1,123 @@
1
+ const JestAnvilReporter = require('./jest-anvil-reporter.js')
2
+ const fs = require('fs')
3
+ const { passedTestResults, failedTestResults, skippedTestResults, combinedTestResults } = require('./test-result-mocks')
4
+
5
+ describe('Jest Anvil reporter', () => {
6
+ const expectedPassedTestResults = {
7
+ test_results: [
8
+ [
9
+ {
10
+
11
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
12
+ line_number: 2,
13
+ status: "passed",
14
+ duration: 3,
15
+ scenario_name: "Example test suite/1 + 1 returns 2",
16
+ description: "1 + 1 returns 2",
17
+ error: null,
18
+ backtrace: null,
19
+ test_type: "unit",
20
+ tag: "platform"
21
+ }
22
+ ]
23
+ ]
24
+ }
25
+
26
+ const expectedFailedTestResults = {
27
+ test_results: [
28
+ [
29
+ {
30
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
31
+ line_number: 2,
32
+ status: "failed",
33
+ duration: 6,
34
+ scenario_name: "Example test suite/1 + 1 returns 3",
35
+ description: "1 + 1 returns 3",
36
+ error: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m",
37
+ backtrace: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:3:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
38
+ test_type: "unit",
39
+ tag: "platform"
40
+ }
41
+ ]
42
+ ]
43
+ }
44
+
45
+ const expectedSkippedTestResults = {
46
+ test_results: [
47
+ [
48
+ {
49
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
50
+ line_number: 2,
51
+ status: "pending",
52
+ duration: 0,
53
+ scenario_name: "Example test suite/1 + 1 returns 2",
54
+ description: "1 + 1 returns 2",
55
+ error: null,
56
+ backtrace: null,
57
+ test_type: "unit",
58
+ tag: "platform"
59
+ }
60
+ ]
61
+ ]
62
+ }
63
+
64
+ const expectedCombinedTestResults = {
65
+ test_results: [
66
+ [
67
+ {
68
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
69
+ line_number: 2,
70
+ status: "passed",
71
+ duration: 5,
72
+ scenario_name: "Example test suite/1 + 1 returns 2 (passed)",
73
+ description: "1 + 1 returns 2 (passed)",
74
+ error: null,
75
+ backtrace: null,
76
+ test_type: "unit",
77
+ tag: "platform"
78
+ },
79
+ {
80
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
81
+ line_number: 6,
82
+ status: "failed",
83
+ duration: 7,
84
+ scenario_name: "Example test suite/1 + 1 returns 3 (failed)",
85
+ description: "1 + 1 returns 3 (failed)",
86
+ error: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m",
87
+ backtrace: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:7:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
88
+ test_type: "unit",
89
+ tag: "platform"
90
+ },
91
+ {
92
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
93
+ line_number: 10,
94
+ status: "pending",
95
+ duration: 0,
96
+ scenario_name: "Example test suite/1 + 1 returns 2 (skipped)",
97
+ description: "1 + 1 returns 2 (skipped)",
98
+ error: null,
99
+ backtrace: null,
100
+ test_type: "unit",
101
+ tag: "platform"
102
+ }
103
+ ]
104
+ ]
105
+ }
106
+
107
+ beforeEach(() => {
108
+ jest.clearAllMocks();
109
+ });
110
+
111
+ test.each`
112
+ input | expectedOutput | testType
113
+ ${passedTestResults} | ${expectedPassedTestResults} | ${"passing tests"}
114
+ ${failedTestResults} | ${expectedFailedTestResults} | ${"failing tests"}
115
+ ${skippedTestResults} | ${expectedSkippedTestResults} | ${"skipped tests"}
116
+ ${combinedTestResults} | ${expectedCombinedTestResults} | ${"a combination of test results"}
117
+ `('returns a payload matching Anvil for $testType', ({ input, expectedOutput, testType }) => {
118
+ const spy = jest.spyOn(fs, 'writeFileSync')
119
+ const jestAnvilReporter = new JestAnvilReporter(undefined, { anvilTag: 'platform' })
120
+ jestAnvilReporter.onRunComplete(undefined, input)
121
+ expect(spy).toBeCalledWith("./anvil_test_results.json", JSON.stringify(expectedOutput, undefined, 2), expect.anything())
122
+ })
123
+ })
@@ -0,0 +1,530 @@
1
+ const passedTestResults = {
2
+ numFailedTestSuites: 0,
3
+ numFailedTests: 0,
4
+ numPassedTestSuites: 1,
5
+ numPassedTests: 1,
6
+ numPendingTestSuites: 0,
7
+ numPendingTests: 0,
8
+ numRuntimeErrorTestSuites: 0,
9
+ numTodoTests: 0,
10
+ numTotalTestSuites: 1,
11
+ numTotalTests: 1,
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: 1635880002363,
33
+ success: false,
34
+ testResults: [
35
+ {
36
+ leaks: false,
37
+ numFailingTests: 0,
38
+ numPassingTests: 1,
39
+ numPendingTests: 0,
40
+ numTodoTests: 0,
41
+ openHandles: [
42
+ ],
43
+ perfStats: {
44
+ end: 1635880004474,
45
+ runtime: 758,
46
+ slow: false,
47
+ start: 1635880003716,
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: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
61
+ testResults: [
62
+ {
63
+ ancestorTitles: [
64
+ "Example test suite",
65
+ ],
66
+ duration: 3,
67
+ failureDetails: [
68
+ ],
69
+ failureMessages: [
70
+ ],
71
+ fullName: "Example test suite 1 + 1 returns 2",
72
+ location: {
73
+ column: 3,
74
+ line: 2,
75
+ },
76
+ numPassingAsserts: 0,
77
+ status: "passed",
78
+ title: "1 + 1 returns 2",
79
+ },
80
+ ],
81
+ console: undefined,
82
+ failureMessage: null,
83
+ displayName: undefined,
84
+ sourceMaps: undefined,
85
+ coverage: undefined,
86
+ },
87
+ ],
88
+ wasInterrupted: false,
89
+ }
90
+
91
+ const failedTestResults = {
92
+ numFailedTestSuites: 1,
93
+ numFailedTests: 1,
94
+ numPassedTestSuites: 0,
95
+ numPassedTests: 0,
96
+ numPendingTestSuites: 0,
97
+ numPendingTests: 0,
98
+ numRuntimeErrorTestSuites: 0,
99
+ numTodoTests: 0,
100
+ numTotalTestSuites: 1,
101
+ numTotalTests: 1,
102
+ openHandles: [
103
+ ],
104
+ snapshot: {
105
+ added: 0,
106
+ didUpdate: false,
107
+ failure: false,
108
+ filesAdded: 0,
109
+ filesRemoved: 0,
110
+ filesRemovedList: [
111
+ ],
112
+ filesUnmatched: 0,
113
+ filesUpdated: 0,
114
+ matched: 0,
115
+ total: 0,
116
+ unchecked: 0,
117
+ uncheckedKeysByFile: [
118
+ ],
119
+ unmatched: 0,
120
+ updated: 0,
121
+ },
122
+ startTime: 1635880063999,
123
+ success: false,
124
+ testResults: [
125
+ {
126
+ leaks: false,
127
+ numFailingTests: 1,
128
+ numPassingTests: 0,
129
+ numPendingTests: 0,
130
+ numTodoTests: 0,
131
+ openHandles: [
132
+ ],
133
+ perfStats: {
134
+ end: 1635880066558,
135
+ runtime: 588,
136
+ slow: false,
137
+ start: 1635880065970,
138
+ },
139
+ skipped: false,
140
+ snapshot: {
141
+ added: 0,
142
+ fileDeleted: false,
143
+ matched: 0,
144
+ unchecked: 0,
145
+ unmatched: 0,
146
+ updated: 0,
147
+ uncheckedKeys: [
148
+ ],
149
+ },
150
+ testFilePath: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
151
+ testResults: [
152
+ {
153
+ ancestorTitles: [
154
+ "Example test suite",
155
+ ],
156
+ duration: 6,
157
+ failureDetails: [
158
+ {
159
+ actual: "",
160
+ error: {
161
+ matcherResult: {
162
+ actual: 2,
163
+ expected: 3,
164
+ message: () => {
165
+ const expectedType = (0, _jestGetType.default)(expected);
166
+ let deepEqualityName = null;
167
+
168
+ if (expectedType !== 'map' && expectedType !== 'set') {
169
+ // If deep equality passes when referential identity fails,
170
+ // but exclude map and set until review of their equality logic.
171
+ if (
172
+ (0, _jasmineUtils.equals)(
173
+ received,
174
+ expected,
175
+ toStrictEqualTesters,
176
+ true
177
+ )
178
+ ) {
179
+ deepEqualityName = 'toStrictEqual';
180
+ } else if (
181
+ (0, _jasmineUtils.equals)(received, expected, [
182
+ _utils.iterableEquality
183
+ ])
184
+ ) {
185
+ deepEqualityName = 'toEqual';
186
+ }
187
+ }
188
+
189
+ return (
190
+ (0, _jestMatcherUtils.matcherHint)(
191
+ matcherName,
192
+ undefined,
193
+ undefined,
194
+ options
195
+ ) +
196
+ '\n\n' +
197
+ (deepEqualityName !== null
198
+ ? (0, _jestMatcherUtils.DIM_COLOR)(
199
+ `If it should pass with deep equality, replace "${matcherName}" with "${deepEqualityName}"`
200
+ ) + '\n\n'
201
+ : '') +
202
+ (0, _jestMatcherUtils.printDiffOrStringify)(
203
+ expected,
204
+ received,
205
+ EXPECTED_LABEL,
206
+ RECEIVED_LABEL,
207
+ isExpand(this.expand)
208
+ )
209
+ );
210
+ },
211
+ name: "toBe",
212
+ pass: false,
213
+ },
214
+ },
215
+ expected: "",
216
+ matcherName: "",
217
+ message: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m",
218
+ passed: false,
219
+ stack: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:3:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
220
+ },
221
+ ],
222
+ failureMessages: [
223
+ "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:3:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
224
+ ],
225
+ fullName: "Example test suite 1 + 1 returns 3",
226
+ location: {
227
+ column: 3,
228
+ line: 2,
229
+ },
230
+ numPassingAsserts: 0,
231
+ status: "failed",
232
+ title: "1 + 1 returns 3",
233
+ },
234
+ ],
235
+ console: undefined,
236
+ failureMessage: "\u001b[1m\u001b[31m \u001b[1m● \u001b[22m\u001b[1mExample test suite › 1 + 1 returns 3\u001b[39m\u001b[22m\n\n \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\n Expected: \u001b[32m3\u001b[39m\n Received: \u001b[31m2\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 1 |\u001b[39m describe(\u001b[32m'Example test suite'\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 2 |\u001b[39m it(\u001b[32m'1 + 1 returns 3'\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 3 |\u001b[39m expect(\u001b[35m1\u001b[39m\u001b[33m+\u001b[39m\u001b[35m1\u001b[39m)\u001b[33m.\u001b[39mtoBe(\u001b[35m3\u001b[39m)\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 4 |\u001b[39m })\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 5 |\u001b[39m })\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 6 |\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[2mat Object.<anonymous> (\u001b[22m\u001b[2m\u001b[0m\u001b[36mpackages/qa/src/reporters/jest-anvil-reporter-mocker.test.js\u001b[39m\u001b[0m\u001b[2m:3:17)\u001b[22m\u001b[2m\u001b[22m\n",
237
+ displayName: undefined,
238
+ sourceMaps: undefined,
239
+ coverage: undefined,
240
+ },
241
+ ],
242
+ wasInterrupted: false,
243
+ }
244
+
245
+ const skippedTestResults = {
246
+ numFailedTestSuites: 0,
247
+ numFailedTests: 0,
248
+ numPassedTestSuites: 0,
249
+ numPassedTests: 0,
250
+ numPendingTestSuites: 1,
251
+ numPendingTests: 1,
252
+ numRuntimeErrorTestSuites: 0,
253
+ numTodoTests: 0,
254
+ numTotalTestSuites: 1,
255
+ numTotalTests: 1,
256
+ openHandles: [
257
+ ],
258
+ snapshot: {
259
+ added: 0,
260
+ didUpdate: false,
261
+ failure: false,
262
+ filesAdded: 0,
263
+ filesRemoved: 0,
264
+ filesRemovedList: [
265
+ ],
266
+ filesUnmatched: 0,
267
+ filesUpdated: 0,
268
+ matched: 0,
269
+ total: 0,
270
+ unchecked: 0,
271
+ uncheckedKeysByFile: [
272
+ ],
273
+ unmatched: 0,
274
+ updated: 0,
275
+ },
276
+ startTime: 1635880126788,
277
+ success: false,
278
+ testResults: [
279
+ {
280
+ leaks: false,
281
+ numFailingTests: 0,
282
+ numPassingTests: 0,
283
+ numPendingTests: 1,
284
+ numTodoTests: 0,
285
+ openHandles: [
286
+ ],
287
+ perfStats: {
288
+ end: 1635880128896,
289
+ runtime: 754,
290
+ slow: false,
291
+ start: 1635880128142,
292
+ },
293
+ skipped: true,
294
+ snapshot: {
295
+ added: 0,
296
+ fileDeleted: false,
297
+ matched: 0,
298
+ unchecked: 0,
299
+ unmatched: 0,
300
+ updated: 0,
301
+ uncheckedKeys: [
302
+ ],
303
+ },
304
+ testFilePath: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
305
+ testResults: [
306
+ {
307
+ ancestorTitles: [
308
+ "Example test suite",
309
+ ],
310
+ duration: 0,
311
+ failureDetails: [
312
+ ],
313
+ failureMessages: [
314
+ ],
315
+ fullName: "Example test suite 1 + 1 returns 2",
316
+ location: {
317
+ column: 3,
318
+ line: 2,
319
+ },
320
+ numPassingAsserts: 0,
321
+ status: "pending",
322
+ title: "1 + 1 returns 2",
323
+ },
324
+ ],
325
+ console: undefined,
326
+ failureMessage: null,
327
+ displayName: undefined,
328
+ sourceMaps: undefined,
329
+ coverage: undefined,
330
+ },
331
+ ],
332
+ wasInterrupted: false,
333
+ }
334
+
335
+ const combinedTestResults = {
336
+ numFailedTestSuites: 1,
337
+ numFailedTests: 1,
338
+ numPassedTestSuites: 0,
339
+ numPassedTests: 1,
340
+ numPendingTestSuites: 0,
341
+ numPendingTests: 1,
342
+ numRuntimeErrorTestSuites: 0,
343
+ numTodoTests: 0,
344
+ numTotalTestSuites: 1,
345
+ numTotalTests: 3,
346
+ openHandles: [
347
+ ],
348
+ snapshot: {
349
+ added: 0,
350
+ didUpdate: false,
351
+ failure: false,
352
+ filesAdded: 0,
353
+ filesRemoved: 0,
354
+ filesRemovedList: [
355
+ ],
356
+ filesUnmatched: 0,
357
+ filesUpdated: 0,
358
+ matched: 0,
359
+ total: 0,
360
+ unchecked: 0,
361
+ uncheckedKeysByFile: [
362
+ ],
363
+ unmatched: 0,
364
+ updated: 0,
365
+ },
366
+ startTime: 1635880588326,
367
+ success: false,
368
+ testResults: [
369
+ {
370
+ leaks: false,
371
+ numFailingTests: 1,
372
+ numPassingTests: 1,
373
+ numPendingTests: 1,
374
+ numTodoTests: 0,
375
+ openHandles: [
376
+ ],
377
+ perfStats: {
378
+ end: 1635880590835,
379
+ runtime: 834,
380
+ slow: false,
381
+ start: 1635880590001,
382
+ },
383
+ skipped: false,
384
+ snapshot: {
385
+ added: 0,
386
+ fileDeleted: false,
387
+ matched: 0,
388
+ unchecked: 0,
389
+ unmatched: 0,
390
+ updated: 0,
391
+ uncheckedKeys: [
392
+ ],
393
+ },
394
+ testFilePath: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
395
+ testResults: [
396
+ {
397
+ ancestorTitles: [
398
+ "Example test suite",
399
+ ],
400
+ duration: 5,
401
+ failureDetails: [
402
+ ],
403
+ failureMessages: [
404
+ ],
405
+ fullName: "Example test suite 1 + 1 returns 2 (passed)",
406
+ location: {
407
+ column: 3,
408
+ line: 2,
409
+ },
410
+ numPassingAsserts: 0,
411
+ status: "passed",
412
+ title: "1 + 1 returns 2 (passed)",
413
+ },
414
+ {
415
+ ancestorTitles: [
416
+ "Example test suite",
417
+ ],
418
+ duration: 7,
419
+ failureDetails: [
420
+ {
421
+ actual: "",
422
+ error: {
423
+ matcherResult: {
424
+ actual: 2,
425
+ expected: 3,
426
+ message: () => {
427
+ const expectedType = (0, _jestGetType.default)(expected);
428
+ let deepEqualityName = null;
429
+
430
+ if (expectedType !== 'map' && expectedType !== 'set') {
431
+ // If deep equality passes when referential identity fails,
432
+ // but exclude map and set until review of their equality logic.
433
+ if (
434
+ (0, _jasmineUtils.equals)(
435
+ received,
436
+ expected,
437
+ toStrictEqualTesters,
438
+ true
439
+ )
440
+ ) {
441
+ deepEqualityName = 'toStrictEqual';
442
+ } else if (
443
+ (0, _jasmineUtils.equals)(received, expected, [
444
+ _utils.iterableEquality
445
+ ])
446
+ ) {
447
+ deepEqualityName = 'toEqual';
448
+ }
449
+ }
450
+
451
+ return (
452
+ (0, _jestMatcherUtils.matcherHint)(
453
+ matcherName,
454
+ undefined,
455
+ undefined,
456
+ options
457
+ ) +
458
+ '\n\n' +
459
+ (deepEqualityName !== null
460
+ ? (0, _jestMatcherUtils.DIM_COLOR)(
461
+ `If it should pass with deep equality, replace "${matcherName}" with "${deepEqualityName}"`
462
+ ) + '\n\n'
463
+ : '') +
464
+ (0, _jestMatcherUtils.printDiffOrStringify)(
465
+ expected,
466
+ received,
467
+ EXPECTED_LABEL,
468
+ RECEIVED_LABEL,
469
+ isExpand(this.expand)
470
+ )
471
+ );
472
+ },
473
+ name: "toBe",
474
+ pass: false,
475
+ },
476
+ },
477
+ expected: "",
478
+ matcherName: "",
479
+ message: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m",
480
+ passed: false,
481
+ stack: "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:7:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
482
+ },
483
+ ],
484
+ failureMessages: [
485
+ "Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m3\u001b[39m\nReceived: \u001b[31m2\u001b[39m\n at Object.<anonymous> (/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js:7:17)\n at Object.asyncJestTest (/davinci/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:45:12\n at new Promise (<anonymous>)\n at mapper (/davinci/node_modules/jest-jasmine2/build/queueRunner.js:28:19)\n at /davinci/node_modules/jest-jasmine2/build/queueRunner.js:75:41",
486
+ ],
487
+ fullName: "Example test suite 1 + 1 returns 3 (failed)",
488
+ location: {
489
+ column: 3,
490
+ line: 6,
491
+ },
492
+ numPassingAsserts: 0,
493
+ status: "failed",
494
+ title: "1 + 1 returns 3 (failed)",
495
+ },
496
+ {
497
+ ancestorTitles: [
498
+ "Example test suite",
499
+ ],
500
+ duration: 0,
501
+ failureDetails: [
502
+ ],
503
+ failureMessages: [
504
+ ],
505
+ fullName: "Example test suite 1 + 1 returns 2 (skipped)",
506
+ location: {
507
+ column: 6,
508
+ line: 10,
509
+ },
510
+ numPassingAsserts: 0,
511
+ status: "pending",
512
+ title: "1 + 1 returns 2 (skipped)",
513
+ },
514
+ ],
515
+ console: undefined,
516
+ failureMessage: "\u001b[1m\u001b[31m \u001b[1m● \u001b[22m\u001b[1mExample test suite › 1 + 1 returns 3 (failed)\u001b[39m\u001b[22m\n\n \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\n Expected: \u001b[32m3\u001b[39m\n Received: \u001b[31m2\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 5 |\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 6 |\u001b[39m it(\u001b[32m'1 + 1 returns 3 (failed)'\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 7 |\u001b[39m expect(\u001b[35m1\u001b[39m\u001b[33m+\u001b[39m\u001b[35m1\u001b[39m)\u001b[33m.\u001b[39mtoBe(\u001b[35m3\u001b[39m)\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 8 |\u001b[39m })\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 9 |\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 10 |\u001b[39m it\u001b[33m.\u001b[39mskip(\u001b[32m'1 + 1 returns 2 (skipped)'\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[2mat Object.<anonymous> (\u001b[22m\u001b[2m\u001b[0m\u001b[36mpackages/qa/src/reporters/jest-anvil-reporter-mocker.test.js\u001b[39m\u001b[0m\u001b[2m:7:17)\u001b[22m\u001b[2m\u001b[22m\n",
517
+ displayName: undefined,
518
+ sourceMaps: undefined,
519
+ coverage: undefined,
520
+ },
521
+ ],
522
+ wasInterrupted: false,
523
+ }
524
+
525
+ module.exports = {
526
+ passedTestResults,
527
+ failedTestResults,
528
+ skippedTestResults,
529
+ combinedTestResults
530
+ }
@@ -0,0 +1,59 @@
1
+ const getPackageFileContentMock = jest.fn()
2
+
3
+ jest.mock('@toptal/davinci-cli-shared', () => ({
4
+ files: {
5
+ getPackageFileContent: getPackageFileContentMock
6
+ }
7
+ }))
8
+
9
+ const jestArgsToCLIRules = require('./jest-args-to-cli-converters')
10
+
11
+ describe('jestArgsToCLIRules "reporters"', () => {
12
+ const reportersRule = jestArgsToCLIRules['reporters']
13
+
14
+ it('converts correctly arrays', () => {
15
+ expect(
16
+ reportersRule(['reporter1', 'reporter2'])
17
+ ).toEqual(['reporter1', 'reporter2'])
18
+ })
19
+
20
+ it('converts correctly string', () => {
21
+ expect(
22
+ reportersRule('reporter1')
23
+ ).toEqual(['reporter1'])
24
+ })
25
+ })
26
+
27
+ describe('jestArgsToCLIRules "setupFilesAfterEnv"', () => {
28
+ const setupFilesAfterEnvRule = jestArgsToCLIRules['setupFilesAfterEnv']
29
+
30
+ it('takes default values from the davinci jest.config.js file', () => {
31
+ getPackageFileContentMock.mockReturnValueOnce({
32
+ setupFilesAfterEnv: ['davinci-setup-files']
33
+ })
34
+
35
+ expect(
36
+ setupFilesAfterEnvRule()
37
+ ).toEqual(['davinci-setup-files'])
38
+ })
39
+
40
+ it('merges default values with passed setup files', () => {
41
+ getPackageFileContentMock.mockReturnValueOnce({
42
+ setupFilesAfterEnv: ['davinci-setup-files']
43
+ })
44
+
45
+ expect(
46
+ setupFilesAfterEnvRule(['file1', 'file2'])
47
+ ).toEqual(['davinci-setup-files', 'file1', 'file2'])
48
+ })
49
+
50
+ it('merges default values with single passed setup file', () => {
51
+ getPackageFileContentMock.mockReturnValueOnce({
52
+ setupFilesAfterEnv: ['davinci-setup-files']
53
+ })
54
+
55
+ expect(
56
+ setupFilesAfterEnvRule('file1')
57
+ ).toEqual(['davinci-setup-files', 'file1'])
58
+ })
59
+ })
@@ -0,0 +1,78 @@
1
+ const styledComponentsVersionCheck = require('./styled-components-version-check')
2
+
3
+ const successTest = (styledComponentsVersion, dependenciesKeys) => {
4
+ const packageJson = {}
5
+
6
+ dependenciesKeys.forEach(dependenciesKey => {
7
+ packageJson[dependenciesKey] = {
8
+ 'styled-components': styledComponentsVersion
9
+ }
10
+ })
11
+
12
+ let error = null
13
+ try {
14
+ styledComponentsVersionCheck(packageJson)
15
+ } catch (e) {
16
+ error = e
17
+ }
18
+
19
+ expect(error).toBeNull()
20
+ }
21
+
22
+ const errorTest = (styledComponentsVersion, dependenciesKeys) => {
23
+ const packageJson = {}
24
+
25
+ dependenciesKeys.forEach(dependenciesKey => {
26
+ packageJson[dependenciesKey] = {
27
+ 'styled-components': styledComponentsVersion
28
+ }
29
+ })
30
+
31
+ let error = null
32
+ try {
33
+ styledComponentsVersionCheck(packageJson)
34
+ } catch (e) {
35
+ error = e
36
+ }
37
+
38
+ expect(error).not.toBeNull()
39
+ expect(error.message).toContain(styledComponentsVersion)
40
+ }
41
+
42
+ describe('styled-components version check', () => {
43
+ describe('has wrong (^4.4.1) SC version in dependencies', () => {
44
+ test('should throw an error', () => {
45
+ errorTest('^4.4.1', ['dependencies'])
46
+ })
47
+ })
48
+
49
+ describe('has correct (^5.0.1) SC version in dependencies', () => {
50
+ test('should NOT throw an error', () => {
51
+ successTest('^5.0.1', ['dependencies'])
52
+ })
53
+ })
54
+
55
+ describe('has wrong (^4.4.1) SC version in devDependencies and peerDependencies', () => {
56
+ test('should throw an error', () => {
57
+ errorTest('^4.4.1', ['devDependencies', 'peerDependencies'])
58
+ })
59
+ })
60
+
61
+ describe('has correct (^5.0.1) SC version in devDependencies and peerDependencies', () => {
62
+ test('should NOT throw an error', () => {
63
+ successTest('^5.0.1', ['devDependencies', 'peerDependencies'])
64
+ })
65
+ })
66
+
67
+ describe('has wrong (^4.4.1) SC version in devDependencies', () => {
68
+ test('should throw an error', () => {
69
+ errorTest('^4.4.1', ['devDependencies'])
70
+ })
71
+ })
72
+
73
+ describe('has correct (^5.0.1) SC version in devDependencies', () => {
74
+ test('should NOT throw an error', () => {
75
+ successTest('^5.0.1', ['devDependencies'])
76
+ })
77
+ })
78
+ })
@@ -0,0 +1,32 @@
1
+ const toJestCLIArguments = require('./to-jest-cli-arguments')
2
+
3
+ const EXAMPLE_REPORTER = 'some-jest-reporter'
4
+ const ARGS_TO_CLI_RESULT = [EXAMPLE_REPORTER]
5
+
6
+ jest.mock('./jest-args-to-cli-converters.js', () => ({
7
+ 'reporters': () => ARGS_TO_CLI_RESULT
8
+ }))
9
+
10
+ describe('toJestCLIArguments', () => {
11
+ it('converts boolean strings to booleans correctly', () => {
12
+ expect(
13
+ toJestCLIArguments({
14
+ cache: 'false',
15
+ ci: 'true'
16
+ })
17
+ ).toEqual({
18
+ cache: false,
19
+ ci: true
20
+ })
21
+ })
22
+
23
+ it('converts some rules by using args-to-cli rules', () => {
24
+ expect(
25
+ toJestCLIArguments({
26
+ 'reporters': EXAMPLE_REPORTER
27
+ })
28
+ ).toEqual({
29
+ 'reporters': ARGS_TO_CLI_RESULT
30
+ })
31
+ })
32
+ })
@@ -1,111 +0,0 @@
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