chore: try jest on new versions

This commit is contained in:
alexander.akait 2023-04-10 04:33:31 +03:00
parent c8da02dfa7
commit 9c3af2f615
4 changed files with 24 additions and 17 deletions

View File

@ -89,9 +89,12 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.x, 17.x] node-version: [10.x, 19.x]
part: [a, b] part: [a, b]
include: include:
- os: ubuntu-latest
node-version: 18.x
part: a
- os: ubuntu-latest - os: ubuntu-latest
node-version: 16.x node-version: 16.x
part: a part: a
@ -110,7 +113,7 @@ jobs:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: "yarn" cache: "yarn"
- run: yarn upgrade jest@^27.5.0 jest-circus@27.5.0 jest-cli@27.5.0 jest-diff@27.5.0 jest-junit@13.0.0 - run: yarn upgrade jest@^27.5.0 jest-circus@27.5.0 jest-cli@27.5.0 jest-diff@27.5.0 jest-junit@13.0.0
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '17.x' if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
- run: yarn --frozen-lockfile - run: yarn --frozen-lockfile
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' if: matrix.node-version == '10.x' || matrix.node-version == '12.x'
- run: yarn link --frozen-lockfile || true - run: yarn link --frozen-lockfile || true

View File

@ -235,7 +235,7 @@
"<rootDir>/schemas", "<rootDir>/schemas",
"<rootDir>/node_modules" "<rootDir>/node_modules"
], ],
"testEnvironment": "node", "testEnvironment": "./test/patch-node-env.js",
"coverageReporters": [ "coverageReporters": [
"json" "json"
], ],

View File

@ -1,18 +1,5 @@
const STATE_SYM = Object.getOwnPropertySymbols(global).find(
Symbol("x").description
? s => s.description === "JEST_STATE_SYMBOL"
: s => s.toString() === "Symbol(JEST_STATE_SYMBOL)"
);
if (!STATE_SYM) {
throw new Error(
`Unable to find JEST_STATE_SYMBOL in ${Object.getOwnPropertySymbols(global)
.map(s => s.toString())
.join(", ")}`
);
}
module.exports = (globalTimeout = 2000, nameSuffix = "") => { module.exports = (globalTimeout = 2000, nameSuffix = "") => {
const state = global[STATE_SYM]; const state = global["JEST_STATE_SYMBOL"];
let currentDescribeBlock; let currentDescribeBlock;
let currentlyRunningTest; let currentlyRunningTest;
let runTests = -1; let runTests = -1;

17
test/patch-node-env.js Normal file
View File

@ -0,0 +1,17 @@
// eslint-disable-next-line node/no-extraneous-require
const NodeEnvironment = require("jest-environment-node").TestEnvironment;
class CustomEnvironment extends NodeEnvironment {
constructor(config, context) {
super(config, context);
}
// Workaround for `Symbol('JEST_STATE_SYMBOL')`
async handleTestEvent(event, state) {
if (!this.global["JEST_STATE_SYMBOL"]) {
this.global["JEST_STATE_SYMBOL"] = state;
}
}
}
module.exports = CustomEnvironment;