@toptal/davinci-qa 6.0.1-alpha-fx-implement-dir-lint.24 → 6.0.2

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
+ ## 6.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1252](https://github.com/toptal/davinci/pull/1252) [`a99253c4`](https://github.com/toptal/davinci/commit/a99253c41eb80f5a31d66766d0efd986d1710bd1) Thanks [@aesqe](https://github.com/aesqe)! - Adds babel-plugin-styled-components to the QA package's Jest config so that the forwardedAs prop is properly working in Jest tests. It also adds the forwardedAs prop to the Skeleton package's react module type.
8
+
3
9
  ## 6.0.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@toptal/davinci-qa",
3
+ "version": "6.0.2",
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.16.4",
34
+ "@babel/preset-react": "^7.10.4",
35
+ "@babel/preset-typescript": "^7.10.4",
36
+ "@cypress/code-coverage": "^3.9.12",
37
+ "@cypress/webpack-preprocessor": "^5.7.0",
38
+ "@testing-library/jest-dom": "^5.14.1",
39
+ "@testing-library/react": "^12.1.2",
40
+ "@toptal/davinci-cli-shared": "1.5.1",
41
+ "@types/jest": "^27.4.1",
42
+ "babel-jest": "^27.5.1",
43
+ "cypress": "^9.4.1",
44
+ "fs-extra": "^10.0.0",
45
+ "glob": "^7.2.0",
46
+ "jest": "^27.5.1",
47
+ "jest-html-reporters": "^3.0.6",
48
+ "jest-junit": "^13.1.0",
49
+ "jest-silent-reporter": "^0.5.0",
50
+ "jest-styled-components": "^7.0.8",
51
+ "jsdom": "^19.0.0",
52
+ "matchmedia-polyfill": "^0.3.2",
53
+ "semver": "^7.3.2",
54
+ "enhanced-resolve": "^5.9.2"
55
+ }
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-qa",
3
- "version": "6.0.1-alpha-fx-implement-dir-lint.24+bad7ab15",
3
+ "version": "6.0.2",
4
4
  "description": "QA package to test your application",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -37,11 +37,10 @@
37
37
  "@cypress/webpack-preprocessor": "^5.7.0",
38
38
  "@testing-library/jest-dom": "^5.14.1",
39
39
  "@testing-library/react": "^12.1.2",
40
- "@toptal/davinci-cli-shared": "1.5.2-alpha-fx-implement-dir-lint.46+bad7ab15",
40
+ "@toptal/davinci-cli-shared": "1.5.1",
41
41
  "@types/jest": "^27.4.1",
42
42
  "babel-jest": "^27.5.1",
43
43
  "cypress": "^9.4.1",
44
- "enhanced-resolve": "^5.9.2",
45
44
  "fs-extra": "^10.0.0",
46
45
  "glob": "^7.2.0",
47
46
  "jest": "^27.5.1",
@@ -51,7 +50,7 @@
51
50
  "jest-styled-components": "^7.0.8",
52
51
  "jsdom": "^19.0.0",
53
52
  "matchmedia-polyfill": "^0.3.2",
54
- "semver": "^7.3.2"
55
- },
56
- "gitHead": "bad7ab1570c417524d4e08364405180094719fb7"
53
+ "semver": "^7.3.2",
54
+ "enhanced-resolve": "^5.9.2"
55
+ }
57
56
  }
@@ -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('yarn', [
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('yarn', [
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
+ })
@@ -0,0 +1,164 @@
1
+ const jestRunCLIMock =jest.fn().mockResolvedValue({ results: {success: true}})
2
+ const getPackageFilePathMock = jest.fn()
3
+ const getProjectRootFilePathMock = jest.fn()
4
+ const getProjectRootFileContentMock = jest.fn().mockReturnValue({
5
+ devDependencies: {}, dependencies: {},
6
+ })
7
+
8
+ jest.mock('@toptal/davinci-cli-shared', () => ({
9
+ runSync: jest.fn(),
10
+ print: {
11
+ green: jest.fn(),
12
+ grey: jest.fn(),
13
+ red: jest.fn(),
14
+ },
15
+ files: {
16
+ getPackageFilePath: getPackageFilePathMock,
17
+ getProjectRootFileContent: getProjectRootFileContentMock,
18
+ getProjectRootFilePath: getProjectRootFilePathMock
19
+ }
20
+ }))
21
+
22
+ jest.mock('jest', () => ({
23
+ runCLI: jestRunCLIMock
24
+ }))
25
+
26
+ const { action } = require('./unit-tests')
27
+ const originalEnv = process.env
28
+
29
+ beforeEach(() => {
30
+ jest.clearAllMocks()
31
+ })
32
+
33
+ afterEach(() => {
34
+ process.env = originalEnv
35
+ })
36
+
37
+ describe('unitTestsCommand', () => {
38
+ describe('when running locally', () => {
39
+ beforeEach(() => {
40
+ delete process.env.CI
41
+ })
42
+
43
+ it('calls the jest CLI without additional reporters', async () => {
44
+ const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
45
+ getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
46
+
47
+ await action({})
48
+
49
+ expect(jestRunCLIMock).toBeCalledWith(
50
+ {"config": davinciJestConfigPath, "testPathPattern": []},
51
+ expect.anything()
52
+ )
53
+ })
54
+
55
+ })
56
+
57
+ describe('when running on CI', () => {
58
+ beforeEach(() => {
59
+ process.env.CI = true
60
+ })
61
+
62
+ it('calls the jest CLI with default Davinci reporters', async () => {
63
+ const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
64
+ getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
65
+
66
+ await action({})
67
+
68
+ expect(jestRunCLIMock).toBeCalledWith(
69
+ expect.objectContaining({
70
+ reporters: [
71
+ [
72
+ "jest-silent-reporter",
73
+ {
74
+ useDots: true,
75
+ showPaths: true,
76
+ showWarnings: true,
77
+ },
78
+ ],
79
+ [
80
+ "jest-junit",
81
+ {
82
+ outputDirectory: "reports",
83
+ },
84
+ ],
85
+ [
86
+ "jest-html-reporters",
87
+ {
88
+ publicPath: "./reports",
89
+ },
90
+ ],
91
+ [
92
+ expect.stringContaining("davinci/packages/qa/src/reporters/jest-anvil-reporter.js"),
93
+ {
94
+ anvilTag: undefined,
95
+ },
96
+ ],
97
+ ],
98
+ }),
99
+ expect.anything()
100
+ )
101
+ })
102
+
103
+ it('allows overriding of the default Davinci reporters via custom configuration', async () => {
104
+ const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
105
+ getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
106
+ const customCLIReporter = 'My-CLI-Reporter'
107
+
108
+ await action({
109
+ options: {
110
+ anvilTag: 'MyTag',
111
+ reporters: customCLIReporter
112
+ }
113
+ })
114
+
115
+ expect(jestRunCLIMock).toBeCalledWith(
116
+ expect.objectContaining({
117
+ reporters: [customCLIReporter],
118
+ }),
119
+ expect.anything()
120
+ )
121
+ })
122
+
123
+ it('allows overriding the default Davinci reporters via custom jest config', async () => {
124
+ const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
125
+ getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
126
+ const customJestConfigReporter = 'My-Jest-Config-Reporter'
127
+
128
+ getProjectRootFileContentMock.mockReturnValue({reporters: customJestConfigReporter})
129
+
130
+ await action({ options: { config: {}}})
131
+
132
+ expect(jestRunCLIMock).toBeCalledWith(
133
+ expect.objectContaining({
134
+ reporters: [customJestConfigReporter],
135
+ }),
136
+ expect.anything()
137
+ )
138
+ })
139
+
140
+ it('prioritizes the CLI reporters over the custom jest config or the default Davinci reporters', async () => {
141
+ const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
142
+ getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
143
+ const customCLIReporter = 'My-CLI-Reporter'
144
+ const customJestConfigReporter = 'My-Jest-Config-Reporter'
145
+
146
+ getProjectRootFileContentMock.mockReturnValue({ reporters: customJestConfigReporter })
147
+
148
+ await action({
149
+ options: {
150
+ anvilTag: 'MyTag',
151
+ reporters: customCLIReporter,
152
+ config: {}
153
+ }
154
+ })
155
+
156
+ expect(jestRunCLIMock).toBeCalledWith(
157
+ expect.objectContaining({
158
+ reporters: [customCLIReporter],
159
+ }),
160
+ expect.anything()
161
+ )
162
+ })
163
+ })
164
+ })
@@ -10,6 +10,9 @@ const babelOptions = {
10
10
  ],
11
11
  '@babel/preset-typescript',
12
12
  '@babel/preset-react'
13
+ ],
14
+ plugins: [
15
+ 'babel-plugin-styled-components'
13
16
  ]
14
17
  }
15
18
 
@@ -0,0 +1,145 @@
1
+ const JestAnvilReporter = require('./jest-anvil-reporter.js')
2
+ const fs = require('fs')
3
+ const {
4
+ passedTestResults,
5
+ failedTestResults,
6
+ skippedTestResults,
7
+ combinedTestResults,
8
+ toDoTestResults
9
+ } = require('./test-result-mocks')
10
+
11
+ describe('Jest Anvil reporter', () => {
12
+ const expectedPassedTestResults = {
13
+ test_results: [
14
+ {
15
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
16
+ line_number: 2,
17
+ status: "passed",
18
+ duration: 3,
19
+ scenario_name: "Example test suite/1 + 1 returns 2",
20
+ description: "1 + 1 returns 2",
21
+ error: null,
22
+ backtrace: null,
23
+ test_type: "unit",
24
+ pending_message: null,
25
+ tag: "platform"
26
+ }
27
+ ]
28
+ }
29
+
30
+ const expectedFailedTestResults = {
31
+ test_results: [
32
+ {
33
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
34
+ line_number: 2,
35
+ status: "failed",
36
+ duration: 6,
37
+ scenario_name: "Example test suite/1 + 1 returns 3",
38
+ description: "1 + 1 returns 3",
39
+ 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",
40
+ 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"],
41
+ test_type: "unit",
42
+ pending_message: null,
43
+ tag: "platform"
44
+ }
45
+ ]
46
+ }
47
+
48
+ const expectedSkippedTestResults = {
49
+ test_results: [
50
+ {
51
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
52
+ line_number: 2,
53
+ status: "pending",
54
+ duration: 0,
55
+ scenario_name: "Example test suite/1 + 1 returns 2",
56
+ description: "1 + 1 returns 2",
57
+ error: null,
58
+ backtrace: null,
59
+ test_type: "unit",
60
+ pending_message: null,
61
+ tag: "platform"
62
+ }
63
+ ]
64
+ }
65
+
66
+ const expectedToDoTestResults = {
67
+ test_results: [
68
+ {
69
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
70
+ line_number: null,
71
+ status: "pending",
72
+ duration: 0,
73
+ scenario_name: "Example test suite/1+1 returns 2",
74
+ description: "1+1 returns 2",
75
+ error: null,
76
+ backtrace: null,
77
+ test_type: "unit",
78
+ pending_message: null,
79
+ tag: "platform"
80
+ }
81
+ ]
82
+ }
83
+
84
+ const expectedCombinedTestResults = {
85
+ test_results: [
86
+ {
87
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
88
+ line_number: 2,
89
+ status: "passed",
90
+ duration: 5,
91
+ scenario_name: "Example test suite/1 + 1 returns 2 (passed)",
92
+ description: "1 + 1 returns 2 (passed)",
93
+ error: null,
94
+ backtrace: null,
95
+ test_type: "unit",
96
+ pending_message: null,
97
+ tag: "platform"
98
+ },
99
+ {
100
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
101
+ line_number: 6,
102
+ status: "failed",
103
+ duration: 7,
104
+ scenario_name: "Example test suite/1 + 1 returns 3 (failed)",
105
+ description: "1 + 1 returns 3 (failed)",
106
+ 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",
107
+ 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"],
108
+ test_type: "unit",
109
+ pending_message: null,
110
+ tag: "platform"
111
+ },
112
+ {
113
+ file_name: "/davinci/packages/qa/src/reporters/jest-anvil-reporter-mocker.test.js",
114
+ line_number: 10,
115
+ status: "pending",
116
+ duration: 0,
117
+ scenario_name: "Example test suite/1 + 1 returns 2 (skipped)",
118
+ description: "1 + 1 returns 2 (skipped)",
119
+ error: null,
120
+ backtrace: null,
121
+ test_type: "unit",
122
+ pending_message: null,
123
+ tag: "platform"
124
+ }
125
+ ]
126
+ }
127
+
128
+ beforeEach(() => {
129
+ jest.clearAllMocks();
130
+ });
131
+
132
+ test.each`
133
+ input | expectedOutput | testType
134
+ ${passedTestResults} | ${expectedPassedTestResults} | ${"passing tests"}
135
+ ${failedTestResults} | ${expectedFailedTestResults} | ${"failing tests"}
136
+ ${skippedTestResults} | ${expectedSkippedTestResults} | ${"skipped tests"}
137
+ ${toDoTestResults} | ${expectedToDoTestResults} | ${"todo tests"}
138
+ ${combinedTestResults} | ${expectedCombinedTestResults} | ${"a combination of test results"}
139
+ `('returns a payload matching Anvil for $testType', ({ input, expectedOutput, testType }) => {
140
+ const spy = jest.spyOn(fs, 'writeFileSync')
141
+ const jestAnvilReporter = new JestAnvilReporter(undefined, { anvilTag: 'platform' })
142
+ jestAnvilReporter.onRunComplete(undefined, input)
143
+ expect(spy).toBeCalledWith("./anvil_test_results.json", JSON.stringify(expectedOutput, undefined, 2), expect.anything())
144
+ })
145
+ })
@@ -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
+ })