Skip to content

Commit

Permalink
Merge pull request #6916 from Sage/jest-flakiness-floating-ui
Browse files Browse the repository at this point in the history
chore: consume JSDOM fix to enhance performance of `window.getComputedStyle`
  • Loading branch information
Parsium authored Sep 2, 2024
2 parents fc716a5 + 48a097c commit 73a0af5
Show file tree
Hide file tree
Showing 32 changed files with 1,789 additions and 3,070 deletions.
89 changes: 82 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions coverage-thresholds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
}
38 changes: 0 additions & 38 deletions jest.config.json

This file was deleted.

37 changes: 37 additions & 0 deletions jest.config.ts
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;
Loading

0 comments on commit 73a0af5

Please sign in to comment.