Skip to content

Commit

Permalink
test: fix jest environment missing structuredClone (#2185)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch authored Jan 9, 2024
1 parent 4ae480e commit f39f9c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/amplify-graphql-transformer-core/FixJestEnvironment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const NodeEnvironment = require('jest-environment-node');

class FixJestEnvironment extends NodeEnvironment {
constructor(...args) {
super(...args);
// https://github.com/jestjs/jest/issues/12628
// sturcturedClone is missing in the jest node environment.
// Newer versions of jest have fixed this, but is not possible to upgrade at this time.
// Newer versions of jest have a performance issue when not used with Node ^20.11.0
// https://github.com/jestjs/jest/issues/11956
// Our minimum supported version is Node 18.
this.global.structuredClone = structuredClone;
}
}

module.exports = FixJestEnvironment;
3 changes: 2 additions & 1 deletion packages/amplify-graphql-transformer-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"coverageReporters": [
"clover",
"text"
]
],
"testEnvironment": "./FixJestEnvironment.js"
}
}

0 comments on commit f39f9c5

Please sign in to comment.