Skip to content

Commit

Permalink
build: store test results (contentful#1369)
Browse files Browse the repository at this point in the history
* build: store test results

* build: use junit reporting

* build: add result hash to filename

* build: testing with combined junit report

* build: testing with combined junit report

* build: remove mochawesome, extract reporting to ci config

* build: use chrome for ct

* build: fix ct command

* build: fix reporter options

* build: fix ct command

* build: add missing \, add jest reporting

* build: add extensible base jest config, jest reporting

* chore: add jest
  • Loading branch information
MayaGillilan authored Mar 14, 2023
1 parent 1e4a7d9 commit 43813b1
Show file tree
Hide file tree
Showing 49 changed files with 1,433 additions and 323 deletions.
19 changes: 16 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
- yarn_install
- run: yarn build
- run: yarn test:ci
- store_test_results:
path: reports

integration-tests:
parameters:
Expand All @@ -77,9 +79,13 @@ jobs:
- run:
command: |
TESTFILES=$(circleci tests glob "cypress/integration/**/*.ts" | circleci tests split --split-by=timings --timings-type=filename | tr '\n' ',')
npx cypress run --spec "${TESTFILES}" --browser << parameters.browser >>
npx cypress run \
--spec "${TESTFILES}" \
--reporter junit \
--reporter-options "mochaFile=./cypress/reports/integration/test-results.[hash].xml" \
--browser << parameters.browser >>
- store_test_results:
path: cypress/results
path: cypress/reports/integration
- store_artifacts:
path: cypress/screenshots
- store_artifacts:
Expand All @@ -94,7 +100,14 @@ jobs:
- run:
name: Run cypress component tests
command: |
yarn cy:run:ct
TESTFILES=$(circleci tests glob cypress/component/**/*.ts | circleci tests split --split-by=timings --timings-type=filename | tr '\n' ',')
npx cypress run-ct \
--spec "${TESTFILES}" \
--reporter junit \
--reporter-options "mochaFile=./cypress/reports/component/test-results.[hash].xml" \
--browser chrome
- store_test_results:
path: cypress/reports/component
- store_artifacts:
path: cypress/videos

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ node_modules
.rts2_cache_esm
.rts2_cache_umd
package-lock.json
/mochawesome-report
build/
dist/
cypress/videos
cypress/screenshots
cypress/reports
cypress.env.json
.vscode/
.turbo
.turbo
reports/
25 changes: 25 additions & 0 deletions baseJestConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable */

function getConfig(packageName) {
return {
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: '../../reports',
outputName: `${packageName}-results.xml`,
addFileAttribute: true,
},
],
],
globals: {
'ts-jest': {
diagnostics: false,
},
},
};
}

module.exports = getConfig;
8 changes: 0 additions & 8 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"baseUrl": "http://localhost:9000",
"reporter": "./node_modules/mochawesome/src/mochawesome.js",
"reporterOptions": {
"mochaFile": "./cypress/reports/mocha/results.xml",
"reportDir": "./cypress/reports/separate-reports",
"overwrite": false,
"html": false,
"json": true
},
"retries": {
"runMode": 2,
"openMode": 0
Expand Down
14 changes: 4 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"docz:dev": "docz dev",
"docz:build": "docz build && cp _redirects .docz/dist",
"cm": "git-cz",
"clean-reports": "rm -rf cypress/reports",
"merge-report": "mochawesome-merge ./cypress/reports/separate-reports/*.json > ./cypress/reports/full_report.json",
"generate-report": "npx mochawesome-report-generator --reportDir cypress/reports cypress/reports/full_report.json",
"prepare": "husky install"
},
"workspaces": [
Expand Down Expand Up @@ -94,10 +91,6 @@
"lerna": "^3.20.2",
"lint-staged": "10.5.4",
"mocha": "^8.0.1",
"mocha-multi-reporters": "^1.5.1",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.0.3",
"mochawesome-report-generator": "^5.1.0",
"prettier": "2.7.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
Expand All @@ -114,7 +107,9 @@
"turbo": "^1.0.23",
"type-fest": "^2.19.0",
"typescript": "^4.4.2",
"webpack": "4.46.0"
"webpack": "4.46.0",
"jest": "29.5.0",
"jest-junit": "15.0.0"
},
"resolutions": {
"@types/react": "^16.14.5",
Expand Down Expand Up @@ -182,6 +177,5 @@
"outputs": []
}
}
},
"dependencies": {}
}
}
10 changes: 10 additions & 0 deletions packages/_shared/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
5 changes: 0 additions & 5 deletions packages/_shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@
"peerDependencies": {
"@contentful/app-sdk": "^4.2.0",
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
]
}
}
10 changes: 10 additions & 0 deletions packages/_test/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
5 changes: 0 additions & 5 deletions packages/_test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,5 @@
"peerDependencies": {
"@contentful/app-sdk": "^4.2.0",
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
]
}
}
10 changes: 10 additions & 0 deletions packages/boolean/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/boolean/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/checkbox/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/date/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/date/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
13 changes: 13 additions & 0 deletions packages/default-field-editors/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
moduleNameMapper: {
'^.+\\.css$': '<rootDir>/src/__mocks__/styles.ts',
},
};
13 changes: 0 additions & 13 deletions packages/default-field-editors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"moduleNameMapper": {
"^.+\\.css$": "<rootDir>/src/__mocks__/styles.ts"
},
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/dropdown/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/dropdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/json/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/list/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
10 changes: 0 additions & 10 deletions packages/list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,5 @@
},
"peerDependencies": {
"react": ">=16.8.0"
},
"jest": {
"testMatch": [
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"globals": {
"ts-jest": {
"diagnostics": false
}
}
}
}
10 changes: 10 additions & 0 deletions packages/location/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */

const baseConfig = require('../../baseJestConfig');

const package = require('./package.json');
const packageName = package.name.split('@contentful/')[1];

module.exports = {
...baseConfig(packageName),
};
Loading

0 comments on commit 43813b1

Please sign in to comment.