-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6916 from Sage/jest-flakiness-floating-ui
chore: consume JSDOM fix to enhance performance of `window.getComputedStyle`
- Loading branch information
Showing
32 changed files
with
1,789 additions
and
3,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,21 +17,96 @@ jobs: | |
- run: npm run type-check | ||
|
||
test: | ||
name: Test with Node ${{ matrix.node }} | ||
name: Test with Node ${{ matrix.node }} (${{ matrix.shard }}, 4) | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: ["18.x", "20.x"] | ||
node: ["18", "20"] | ||
shard: [1, 2, 3, 4] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- run: npm ci | ||
- run: | | ||
npm test -- --ci --maxWorkers=4 --shard=${{ matrix.shard }} --colors | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run test shard | ||
run: | | ||
npm test -- --ci --maxWorkers=4 --shard=${{ matrix.shard }}/4 --colors --coverage --coverageReporters="json" | ||
- name: Rename shard coverage report | ||
run: | | ||
mv coverage/coverage-final.json coverage/${{ matrix.shard }}.json | ||
- name: Upload coverage report for shard | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage-node-${{ matrix.node }}-shard-${{ matrix.shard }} | ||
path: coverage/${{ matrix.shard }}.json | ||
retention-days: 1 | ||
|
||
get-thresholds: | ||
name: Get global coverage thresholds | ||
runs-on: ubuntu-latest | ||
needs: test | ||
outputs: | ||
globalThresholds: ${{ steps.extract-thresholds.outputs.globalThresholds }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: extract-thresholds | ||
run: | | ||
echo "globalThresholds=$(jq -r -c '.global' coverage-thresholds.json)" >> $GITHUB_OUTPUT | ||
check-coverage: | ||
name: Check global coverage with Node ${{ matrix.node }} | ||
runs-on: ubuntu-latest | ||
needs: get-thresholds | ||
|
||
env: | ||
globalThresholds: ${{ needs.get-thresholds.outputs.globalThresholds }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: ["18", "20"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
cache: npm | ||
|
||
- name: Install nyc | ||
run: npm install [email protected] --save-dev | ||
|
||
- name: Download shard coverage reports | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: coverage-node-${{ matrix.node }}-shard-* | ||
path: coverage | ||
merge-multiple: true | ||
|
||
- name: Merge shard coverage reports | ||
run: | | ||
npx nyc merge coverage merged-coverage.json | ||
- name: Output report | ||
run: | | ||
npx nyc report --temp-dir coverage --reporter text >> $GITHUB_STEP_SUMMARY | ||
env: | ||
CONTAINER: ${{ matrix.shard }} | ||
- name: Validate coverage threshold | ||
run: | | ||
npx nyc check-coverage --temp-dir coverage \ | ||
--functions ${{ fromJSON(env.globalThresholds).functions }} \ | ||
--branches ${{ fromJSON(env.globalThresholds).branches }} \ | ||
--lines ${{ fromJSON(env.globalThresholds).lines }} \ | ||
--statements ${{ fromJSON(env.globalThresholds).statements }} \ | ||
&& (echo "✅ Global coverage meets global thresholds" && exit 0) \ | ||
|| (echo "❌ Global coverage does not meet global thresholds!" && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"global": { | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Config } from "jest"; | ||
import coverageThresholds from "./coverage-thresholds.json"; | ||
|
||
const isCI = process.env.CI === "true"; | ||
|
||
const config: Config = { | ||
notify: false, | ||
setupFiles: ["raf/polyfill", "<rootDir>/enzyme.config.js"], | ||
testEnvironment: "jsdom", | ||
setupFilesAfterEnv: [ | ||
"<rootDir>/src/__spec_helper__/__internal__/index.ts", | ||
"<rootDir>/src/__spec_helper__/__internal__/expect.ts", | ||
"jest-canvas-mock", | ||
], | ||
snapshotSerializers: ["enzyme-to-json/serializer"], | ||
testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"], | ||
testPathIgnorePatterns: ["node_modules", "lib", "esm"], | ||
moduleDirectories: ["src", "node_modules"], | ||
collectCoverage: true, | ||
coveragePathIgnorePatterns: [ | ||
"node_modules", | ||
"src/__spec_helper__", | ||
"src/locales", | ||
"lib", | ||
"esm", | ||
], | ||
coverageReporters: ["text-summary", "html"], | ||
coverageDirectory: "<rootDir>/coverage", | ||
coverageThreshold: isCI ? undefined : coverageThresholds, | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "mjs"], | ||
transform: { | ||
"^.+\\.(js|mjs|jsx|ts|tsx)$": "babel-jest", | ||
"^.+\\.svg$": "<rootDir>/svgTransform.mjs", | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.