@toptal/davinci-qa 9.0.1 → 10.0.1-alpha-FX-2187-component-testing-support.6
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 +6 -0
- package/README.md +18 -23
- package/package.json +7 -7
- package/src/commands/integration-open.js +47 -0
- package/src/commands/{integration-tests.js → integration-run.js} +12 -15
- package/src/configs/cypress.config.js +39 -0
- package/src/index.js +4 -2
- package/dist-package/package.json +0 -62
- package/src/commands/integration-tests.test.js +0 -69
- package/src/commands/unit-tests.test.js +0 -213
- package/src/configs/cypress/plugins/__snapshots__/extends.test.js.snap +0 -28
- package/src/configs/cypress/plugins/config-with-extends.test.json +0 -4
- package/src/configs/cypress/plugins/config-without-extends.test.json +0 -3
- package/src/configs/cypress/plugins/extends.test.js +0 -43
- package/src/configs/cypress/plugins/index.js +0 -22
- package/src/configs/cypress.config.json +0 -12
- package/src/reporters/anvil-results-helper.test.js +0 -87
- package/src/reporters/cypress-anvil-reporter.test.js +0 -271
- package/src/reporters/jest-anvil-reporter.test.js +0 -223
- package/src/utils/jest-args-to-cli-converters.test.js +0 -59
- package/src/utils/styled-components-version-check.test.js +0 -81
- package/src/utils/to-jest-cli-arguments.test.js +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1355](https://github.com/toptal/davinci/pull/1355) [`a59617c3`](https://github.com/toptal/davinci/commit/a59617c33ad153b1aaff797dd3492dc3d3678ca0) Thanks [@TomasSlama](https://github.com/TomasSlama)! - Update Cypress to v10. Follow [migration guide](https://docs.cypress.io/guides/references/migration-guide)
|
|
8
|
+
|
|
3
9
|
## 9.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -29,12 +29,12 @@ Example of execution unit tests in two separate threads:
|
|
|
29
29
|
```
|
|
30
30
|
GROUP_INDEX=0 GROUP_TOTAL=2 davinci qa unit --ci
|
|
31
31
|
GROUP_INDEX=1 GROUP_TOTAL=2 davinci qa unit --ci
|
|
32
|
-
|
|
32
|
+
```
|
|
33
33
|
|
|
34
34
|
To specify a Sequencer, need to specify two environment variables:
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
- `GROUP_INDEX` — The current worker index
|
|
37
|
+
- `GROUP_TOTAL` — Total amount of workers
|
|
38
38
|
|
|
39
39
|
[Jest CLI docs](https://jestjs.io/docs/en/cli)
|
|
40
40
|
|
|
@@ -42,38 +42,33 @@ To specify a Sequencer, need to specify two environment variables:
|
|
|
42
42
|
|
|
43
43
|
#### Integration
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`davinci qa integration`
|
|
45
|
+
| command | description |
|
|
46
|
+
| ----------------------------- | ---------------------------------------- |
|
|
47
|
+
| `davinci qa integration open` | Open Cypress Test Runner app |
|
|
48
|
+
| `davinci qa integration run` | Run cypress tests without the cypress ui |
|
|
48
49
|
|
|
49
50
|
Options:
|
|
50
51
|
|
|
51
|
-
- `--
|
|
52
|
+
- `--anvilTag`(_run only_): the project name matching Anvil's expected tag to generate Anvil Reports
|
|
53
|
+
- `--baseUrl`: URL used as prefix for cy.visit() or cy.request() command's URL
|
|
52
54
|
- Any other cypress option (ex. `--parallel`)
|
|
53
55
|
|
|
54
56
|
[Cypress CLI docs](https://docs.cypress.io/guides/guides/command-line.html)
|
|
55
57
|
|
|
56
58
|
#### Extending Cypress config
|
|
57
59
|
|
|
58
|
-
By default [cypress.config.
|
|
60
|
+
By default [cypress.config.js](https://github.com/toptal/davinci/blob/0f1f1485433573baeca66cf0c379259ca21b3f2f/packages/qa/src/configs/cypress.config.js#L1) is used.
|
|
59
61
|
|
|
60
|
-
To extend default config, create `/cypress.
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"extends": "@toptal/davinci-qa/src/configs/cypress.config.json",
|
|
64
|
-
...other custom configs
|
|
65
|
-
}
|
|
66
|
-
````
|
|
62
|
+
To extend default config, create `/cypress.config.js` file in the root of the project and spread the default config into yours:
|
|
67
63
|
|
|
68
|
-
In `/cypress/plugins/index.js` file add:
|
|
69
64
|
```js
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...
|
|
75
|
-
|
|
76
|
-
}
|
|
65
|
+
const davinciConfig = require('@toptal/davinci-qa/src/configs/cypress.config.js')
|
|
66
|
+
|
|
67
|
+
export default defineConfig({
|
|
68
|
+
...davinciConfig,
|
|
69
|
+
e2e: { ...davinciConfig.e2e, ...custom },
|
|
70
|
+
component: { ...davinciConfig.component, ...custom },
|
|
71
|
+
})
|
|
77
72
|
```
|
|
78
73
|
|
|
79
74
|
### Alias
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/davinci-qa",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1-alpha-FX-2187-component-testing-support.6+093204cf",
|
|
4
4
|
"description": "QA package to test your application",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,15 +33,14 @@
|
|
|
33
33
|
"@babel/preset-env": "^7.18.0",
|
|
34
34
|
"@babel/preset-react": "^7.17.12",
|
|
35
35
|
"@babel/preset-typescript": "^7.17.12",
|
|
36
|
-
"@
|
|
37
|
-
"@cypress/
|
|
38
|
-
"@cypress/webpack-preprocessor": "^5.11.0",
|
|
36
|
+
"@cypress/code-coverage": "^3.10.0",
|
|
37
|
+
"@cypress/webpack-preprocessor": "^5.12.0",
|
|
39
38
|
"@testing-library/jest-dom": "^5.16.4",
|
|
40
39
|
"@testing-library/react": "^12.1.2",
|
|
41
|
-
"@toptal/davinci-cli-shared": "1.5.
|
|
40
|
+
"@toptal/davinci-cli-shared": "1.5.3-alpha-FX-2187-component-testing-support.18+093204cf",
|
|
42
41
|
"@types/jest": "^27.5.1",
|
|
43
42
|
"babel-jest": "^28.1.0",
|
|
44
|
-
"cypress": "^
|
|
43
|
+
"cypress": "^10.0.3",
|
|
45
44
|
"enhanced-resolve": "^5.9.2",
|
|
46
45
|
"fs-extra": "^10.0.0",
|
|
47
46
|
"glob": "^8.0.3",
|
|
@@ -58,5 +57,6 @@
|
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"json5": "^2.2.1",
|
|
60
59
|
"mocha": "^10.0.0"
|
|
61
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"gitHead": "093204cf21a6042384d26ddce00f103dcb3f3795"
|
|
62
62
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const {
|
|
2
|
+
runSync,
|
|
3
|
+
print,
|
|
4
|
+
convertToCLIParameters,
|
|
5
|
+
files,
|
|
6
|
+
} = require('@toptal/davinci-cli-shared')
|
|
7
|
+
|
|
8
|
+
const integrationOpenCommand = ({
|
|
9
|
+
options: { baseUrl, ...cypressOptions } = {},
|
|
10
|
+
files: testFiles = [],
|
|
11
|
+
}) => {
|
|
12
|
+
print.green('Running integration tests...')
|
|
13
|
+
|
|
14
|
+
const configPath = files.getPackageFilePath(
|
|
15
|
+
'@toptal/davinci-qa',
|
|
16
|
+
'src/configs/cypress.config.json'
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
runSync('yarn', [
|
|
20
|
+
'cypress',
|
|
21
|
+
'open',
|
|
22
|
+
'--config-file',
|
|
23
|
+
configPath,
|
|
24
|
+
...testFiles,
|
|
25
|
+
...(baseUrl ? ['--config', `baseUrl=${baseUrl}`] : []),
|
|
26
|
+
...convertToCLIParameters(cypressOptions),
|
|
27
|
+
])
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const integrationOpenCommandCreator = {
|
|
31
|
+
action: ({ options, files: filesArg }) => {
|
|
32
|
+
return integrationOpenCommand({
|
|
33
|
+
files: filesArg,
|
|
34
|
+
options: { ...options },
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
allowUnknownOptions: true,
|
|
38
|
+
command: 'integration open [files...]',
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
label: "URL used as prefix for cy.visit() or cy.request() command's URL",
|
|
42
|
+
name: '--baseUrl <baseUrl>',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = integrationOpenCommandCreator
|
|
@@ -5,31 +5,29 @@ const {
|
|
|
5
5
|
files,
|
|
6
6
|
} = require('@toptal/davinci-cli-shared')
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
options: {
|
|
8
|
+
const integrationRunCommand = ({
|
|
9
|
+
options: { baseUrl, anvilTag, ...cypressOptions } = {},
|
|
10
10
|
files: testFiles = [],
|
|
11
11
|
}) => {
|
|
12
12
|
print.green('Running integration tests...')
|
|
13
13
|
|
|
14
14
|
const configPath = files.getPackageFilePath(
|
|
15
15
|
'@toptal/davinci-qa',
|
|
16
|
-
'src/configs/cypress.config.
|
|
16
|
+
'src/configs/cypress.config.js'
|
|
17
17
|
)
|
|
18
18
|
const cypressReporterPath = files.getPackageFilePath(
|
|
19
19
|
'@toptal/davinci-qa',
|
|
20
20
|
'src/reporters/cypress-anvil-reporter.js'
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
-
const mode = open ? 'open' : 'run'
|
|
24
|
-
|
|
25
23
|
runSync('yarn', [
|
|
26
24
|
'cypress',
|
|
27
|
-
|
|
25
|
+
'run',
|
|
28
26
|
'--config-file',
|
|
29
27
|
configPath,
|
|
30
28
|
...testFiles,
|
|
31
29
|
...(baseUrl ? ['--config', `baseUrl=${baseUrl}`] : []),
|
|
32
|
-
...(
|
|
30
|
+
...(anvilTag
|
|
33
31
|
? [
|
|
34
32
|
'--reporter',
|
|
35
33
|
cypressReporterPath,
|
|
@@ -41,17 +39,16 @@ const integrationTestCommand = ({
|
|
|
41
39
|
])
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
const
|
|
42
|
+
const integrationRunCommandCreator = {
|
|
45
43
|
action: ({ options, files: filesArg }) => {
|
|
46
|
-
return
|
|
44
|
+
return integrationRunCommand({
|
|
45
|
+
files: filesArg,
|
|
46
|
+
options: { ...options },
|
|
47
|
+
})
|
|
47
48
|
},
|
|
48
49
|
allowUnknownOptions: true,
|
|
49
|
-
command: 'integration [files...]',
|
|
50
|
+
command: 'integration run [files...]',
|
|
50
51
|
options: [
|
|
51
|
-
{
|
|
52
|
-
label: 'opens the Cypress Test Runner',
|
|
53
|
-
name: '--open',
|
|
54
|
-
},
|
|
55
52
|
{
|
|
56
53
|
label: "URL used as prefix for cy.visit() or cy.request() command's URL",
|
|
57
54
|
name: '--baseUrl <baseUrl>',
|
|
@@ -64,4 +61,4 @@ const integrationCommandCreator = {
|
|
|
64
61
|
],
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
module.exports =
|
|
64
|
+
module.exports = integrationRunCommandCreator
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const { defineConfig } = require('cypress')
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
webpackPreprocessor,
|
|
5
|
+
} = require('./cypress/plugins/webpack-preprocessor')
|
|
6
|
+
const parallelization = require('./cypress/plugins/parallelization')
|
|
7
|
+
|
|
8
|
+
module.exports = defineConfig({
|
|
9
|
+
defaultCommandTimeout: 6000,
|
|
10
|
+
fixturesFolder: './cypress/fixtures',
|
|
11
|
+
chromeWebSecurity: false,
|
|
12
|
+
screenshotsFolder: './cypress/screenshots',
|
|
13
|
+
video: false,
|
|
14
|
+
|
|
15
|
+
component: {
|
|
16
|
+
viewportWidth: 1280,
|
|
17
|
+
viewportHeight: 1024,
|
|
18
|
+
slowTestThreshold: 250,
|
|
19
|
+
specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}',
|
|
20
|
+
supportFile: 'cypress/support/component.{js,ts}',
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
e2e: {
|
|
24
|
+
setupNodeEvents(on, config) {
|
|
25
|
+
// generate code coverage
|
|
26
|
+
require('@cypress/code-coverage/task')(on, config)
|
|
27
|
+
|
|
28
|
+
// split spec files in CI
|
|
29
|
+
parallelization(config)
|
|
30
|
+
|
|
31
|
+
// instrument code for code coverage
|
|
32
|
+
on('file:preprocessor', webpackPreprocessor)
|
|
33
|
+
},
|
|
34
|
+
baseUrl: 'http://0.0.0.0:3000',
|
|
35
|
+
slowTestThreshold: 10000,
|
|
36
|
+
specPattern: 'cypress/integration/**/*.spec.{js,jsx,ts,tsx}',
|
|
37
|
+
supportFile: 'cypress/support/e2e.{js,ts}',
|
|
38
|
+
},
|
|
39
|
+
})
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const unitTestsCommandCreator = require('./commands/unit-tests')
|
|
2
|
-
const
|
|
2
|
+
const integrationOpenCommandCreator = require('./commands/integration-open')
|
|
3
|
+
const integrationRunCommandCreator = require('./commands/integration-run')
|
|
3
4
|
const codeMetricsCommandCreator = require('./commands/code-metrics')
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
commands: [
|
|
7
8
|
unitTestsCommandCreator,
|
|
8
|
-
|
|
9
|
+
integrationOpenCommandCreator,
|
|
10
|
+
integrationRunCommandCreator,
|
|
9
11
|
codeMetricsCommandCreator,
|
|
10
12
|
],
|
|
11
13
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@toptal/davinci-qa",
|
|
3
|
-
"version": "9.0.1",
|
|
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.18.0",
|
|
33
|
-
"@babel/preset-env": "^7.18.0",
|
|
34
|
-
"@babel/preset-react": "^7.17.12",
|
|
35
|
-
"@babel/preset-typescript": "^7.17.12",
|
|
36
|
-
"@bahmutov/cypress-extends": "^1.1.0",
|
|
37
|
-
"@cypress/code-coverage": "^3.9.12",
|
|
38
|
-
"@cypress/webpack-preprocessor": "^5.11.0",
|
|
39
|
-
"@testing-library/jest-dom": "^5.16.4",
|
|
40
|
-
"@testing-library/react": "^12.1.2",
|
|
41
|
-
"@toptal/davinci-cli-shared": "1.5.2",
|
|
42
|
-
"@types/jest": "^27.5.1",
|
|
43
|
-
"babel-jest": "^28.1.0",
|
|
44
|
-
"cypress": "^9.7.0",
|
|
45
|
-
"enhanced-resolve": "^5.9.2",
|
|
46
|
-
"fs-extra": "^10.0.0",
|
|
47
|
-
"glob": "^8.0.3",
|
|
48
|
-
"jest": "^28.1.0",
|
|
49
|
-
"jest-environment-jsdom": "^28.1.0",
|
|
50
|
-
"jest-html-reporters": "^3.0.6",
|
|
51
|
-
"jest-junit": "^13.1.0",
|
|
52
|
-
"jest-silent-reporter": "^0.5.0",
|
|
53
|
-
"jest-styled-components": "^7.0.8",
|
|
54
|
-
"jsdom": "^19.0.0",
|
|
55
|
-
"matchmedia-polyfill": "^0.3.2",
|
|
56
|
-
"semver": "^7.3.2"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"json5": "^2.2.1",
|
|
60
|
-
"mocha": "^10.0.0"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
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('./integration-tests')
|
|
18
|
-
|
|
19
|
-
describe('integrationTestCommand', () => {
|
|
20
|
-
it('runs cypress with default options', () => {
|
|
21
|
-
convertToCLIParametersMock.mockReturnValueOnce([])
|
|
22
|
-
getPackageFilePathMock.mockReturnValueOnce(
|
|
23
|
-
'packages/qa/src/configs/cypress.config.json'
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
action({ options: {} })
|
|
27
|
-
|
|
28
|
-
expect(runSync).toHaveBeenCalledWith('yarn', [
|
|
29
|
-
'cypress',
|
|
30
|
-
'run',
|
|
31
|
-
'--config-file',
|
|
32
|
-
'packages/qa/src/configs/cypress.config.json',
|
|
33
|
-
])
|
|
34
|
-
|
|
35
|
-
expect(convertToCLIParametersMock).toHaveBeenCalledWith({})
|
|
36
|
-
expect(getPackageFilePathMock).toHaveBeenCalledWith(
|
|
37
|
-
'@toptal/davinci-qa',
|
|
38
|
-
'src/configs/cypress.config.json'
|
|
39
|
-
)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('runs cypress with custom options', () => {
|
|
43
|
-
const spec = 'cypress/integration/activation_flow.spec.ts'
|
|
44
|
-
|
|
45
|
-
convertToCLIParametersMock.mockReturnValueOnce(['--spec', spec])
|
|
46
|
-
getPackageFilePathMock.mockReturnValueOnce(
|
|
47
|
-
'packages/qa/src/configs/cypress.config.json'
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
action({ options: { spec } })
|
|
51
|
-
|
|
52
|
-
expect(runSync).toHaveBeenCalledWith('yarn', [
|
|
53
|
-
'cypress',
|
|
54
|
-
'run',
|
|
55
|
-
'--config-file',
|
|
56
|
-
'packages/qa/src/configs/cypress.config.json',
|
|
57
|
-
'--spec',
|
|
58
|
-
spec,
|
|
59
|
-
])
|
|
60
|
-
|
|
61
|
-
expect(convertToCLIParametersMock).toHaveBeenCalledWith({
|
|
62
|
-
spec,
|
|
63
|
-
})
|
|
64
|
-
expect(getPackageFilePathMock).toHaveBeenCalledWith(
|
|
65
|
-
'@toptal/davinci-qa',
|
|
66
|
-
'src/configs/cypress.config.json'
|
|
67
|
-
)
|
|
68
|
-
})
|
|
69
|
-
})
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
const jestRunCLIMock = jest
|
|
2
|
-
.fn()
|
|
3
|
-
.mockResolvedValue({ results: { success: true } })
|
|
4
|
-
const getPackageFilePathMock = jest.fn()
|
|
5
|
-
const getProjectRootFilePathMock = jest.fn()
|
|
6
|
-
const getProjectRootFileContentMock = jest.fn().mockReturnValue({
|
|
7
|
-
devDependencies: {},
|
|
8
|
-
dependencies: {},
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
jest.mock('@toptal/davinci-cli-shared', () => ({
|
|
12
|
-
runSync: jest.fn(),
|
|
13
|
-
print: {
|
|
14
|
-
green: jest.fn(),
|
|
15
|
-
grey: jest.fn(),
|
|
16
|
-
red: jest.fn(),
|
|
17
|
-
},
|
|
18
|
-
files: {
|
|
19
|
-
getPackageFilePath: getPackageFilePathMock,
|
|
20
|
-
getProjectRootFileContent: getProjectRootFileContentMock,
|
|
21
|
-
getProjectRootFilePath: getProjectRootFilePathMock,
|
|
22
|
-
},
|
|
23
|
-
}))
|
|
24
|
-
|
|
25
|
-
jest.mock('jest', () => ({
|
|
26
|
-
runCLI: jestRunCLIMock,
|
|
27
|
-
}))
|
|
28
|
-
|
|
29
|
-
const { action } = require('./unit-tests')
|
|
30
|
-
const originalEnv = process.env
|
|
31
|
-
|
|
32
|
-
describe('unitTestsCommand', () => {
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
jest.clearAllMocks()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
process.env = originalEnv
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('when running locally', () => {
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
delete process.env.CI
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('calls the jest CLI without additional reporters', async () => {
|
|
47
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
48
|
-
|
|
49
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
50
|
-
|
|
51
|
-
await action({})
|
|
52
|
-
|
|
53
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
54
|
-
{ config: davinciJestConfigPath, testPathPattern: [] },
|
|
55
|
-
expect.anything()
|
|
56
|
-
)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
describe('when running on CI', () => {
|
|
61
|
-
beforeEach(() => {
|
|
62
|
-
process.env.CI = true
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('calls the jest CLI with default Davinci reporters', async () => {
|
|
66
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
67
|
-
|
|
68
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
69
|
-
|
|
70
|
-
await action({})
|
|
71
|
-
|
|
72
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
73
|
-
expect.objectContaining({
|
|
74
|
-
reporters: [
|
|
75
|
-
[
|
|
76
|
-
'jest-silent-reporter',
|
|
77
|
-
{
|
|
78
|
-
useDots: true,
|
|
79
|
-
showPaths: true,
|
|
80
|
-
showWarnings: true,
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
[
|
|
84
|
-
'jest-junit',
|
|
85
|
-
{
|
|
86
|
-
outputDirectory: 'reports',
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
'jest-html-reporters',
|
|
91
|
-
{
|
|
92
|
-
publicPath: './reports',
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
],
|
|
96
|
-
}),
|
|
97
|
-
expect.anything()
|
|
98
|
-
)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('returns the anvil reporter when anvilTag is set', async () => {
|
|
102
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
103
|
-
|
|
104
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
105
|
-
|
|
106
|
-
await action({ options: { anvilTag: 'platform' } })
|
|
107
|
-
|
|
108
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
109
|
-
expect.objectContaining({
|
|
110
|
-
reporters: [
|
|
111
|
-
[
|
|
112
|
-
'jest-silent-reporter',
|
|
113
|
-
{
|
|
114
|
-
useDots: true,
|
|
115
|
-
showPaths: true,
|
|
116
|
-
showWarnings: true,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
'jest-junit',
|
|
121
|
-
{
|
|
122
|
-
outputDirectory: 'reports',
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
'jest-html-reporters',
|
|
127
|
-
{
|
|
128
|
-
publicPath: './reports',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
[
|
|
132
|
-
expect.stringContaining(
|
|
133
|
-
'davinci/packages/qa/src/reporters/jest-anvil-reporter.js'
|
|
134
|
-
),
|
|
135
|
-
{
|
|
136
|
-
anvilTag: 'platform',
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
],
|
|
140
|
-
}),
|
|
141
|
-
expect.anything()
|
|
142
|
-
)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
it('allows overriding of the default Davinci reporters via custom configuration', async () => {
|
|
146
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
147
|
-
|
|
148
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
149
|
-
const customCLIReporter = 'My-CLI-Reporter'
|
|
150
|
-
|
|
151
|
-
await action({
|
|
152
|
-
options: {
|
|
153
|
-
anvilTag: 'MyTag',
|
|
154
|
-
reporters: customCLIReporter,
|
|
155
|
-
},
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
159
|
-
expect.objectContaining({
|
|
160
|
-
reporters: [customCLIReporter],
|
|
161
|
-
}),
|
|
162
|
-
expect.anything()
|
|
163
|
-
)
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it('allows overriding the default Davinci reporters via custom jest config', async () => {
|
|
167
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
168
|
-
|
|
169
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
170
|
-
const customJestConfigReporter = 'My-Jest-Config-Reporter'
|
|
171
|
-
|
|
172
|
-
getProjectRootFileContentMock.mockReturnValue({
|
|
173
|
-
reporters: customJestConfigReporter,
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
await action({ options: { config: {} } })
|
|
177
|
-
|
|
178
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
179
|
-
expect.objectContaining({
|
|
180
|
-
reporters: [customJestConfigReporter],
|
|
181
|
-
}),
|
|
182
|
-
expect.anything()
|
|
183
|
-
)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('prioritizes the CLI reporters over the custom jest config or the default Davinci reporters', async () => {
|
|
187
|
-
const davinciJestConfigPath = 'packages/qa/src/configs/jest.config.js'
|
|
188
|
-
|
|
189
|
-
getPackageFilePathMock.mockReturnValueOnce(davinciJestConfigPath)
|
|
190
|
-
const customCLIReporter = 'My-CLI-Reporter'
|
|
191
|
-
const customJestConfigReporter = 'My-Jest-Config-Reporter'
|
|
192
|
-
|
|
193
|
-
getProjectRootFileContentMock.mockReturnValue({
|
|
194
|
-
reporters: customJestConfigReporter,
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
await action({
|
|
198
|
-
options: {
|
|
199
|
-
anvilTag: 'MyTag',
|
|
200
|
-
reporters: customCLIReporter,
|
|
201
|
-
config: {},
|
|
202
|
-
},
|
|
203
|
-
})
|
|
204
|
-
|
|
205
|
-
expect(jestRunCLIMock).toHaveBeenCalledWith(
|
|
206
|
-
expect.objectContaining({
|
|
207
|
-
reporters: [customCLIReporter],
|
|
208
|
-
}),
|
|
209
|
-
expect.anything()
|
|
210
|
-
)
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`cypress extends tests when "extends" key exists in the source config file merges extended config into source config 1`] = `
|
|
4
|
-
"{
|
|
5
|
-
configFile: '@toptal/davinci-qa/src/configs/cypress/plugins/config-with-extends.test.json',
|
|
6
|
-
fixturesFolder: './cypress/fixtures',
|
|
7
|
-
integrationFolder: '.',
|
|
8
|
-
screenshotsFolder: './cypress/screenshots',
|
|
9
|
-
testFiles: [
|
|
10
|
-
'cypress/**/spec.{js,ts}',
|
|
11
|
-
'cypress/**/*.spec.{js,ts}',
|
|
12
|
-
],
|
|
13
|
-
ignoreTestFiles: '**/node_modules/**/*',
|
|
14
|
-
pluginsFile: './cypress/plugins/index.js',
|
|
15
|
-
baseUrl: 'http://0.0.0.0:3000',
|
|
16
|
-
chromeWebSecurity: false,
|
|
17
|
-
defaultCommandTimeout: 1000,
|
|
18
|
-
video: false,
|
|
19
|
-
extends: '@toptal/davinci-qa/src/configs/cypress.config.json',
|
|
20
|
-
}"
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
exports[`cypress extends tests when no "extends" exist in the source config file returns source config file without any change 1`] = `
|
|
24
|
-
"{
|
|
25
|
-
configFile: '@toptal/davinci-qa/src/configs/cypress/plugins/config-without-extends.test.json',
|
|
26
|
-
defaultCommandTimeout: 1000,
|
|
27
|
-
}"
|
|
28
|
-
`;
|