feat: migrate unit tests to Jest (#6353)
* config(jest): updated setup * config(jest): update testMatch to include jsx files * config(jest): add transformIgnorePatterns * config(jest): update ignore files that do not work in jest yet * config: add test:unit-jest to test script * fix(jest): lint with eslint-plugin-jest * refactor(jest): move unit test directory * refactor(mocha): restore mocha tests that fail in jest * docs(jest): update helpful scripts with test:unit-jest
This commit is contained in:
19
test/unit/setup.js
Normal file
19
test/unit/setup.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import win from "../../src/core/window"
|
||||
|
||||
function copyProps(src, target) {
|
||||
const props = Object.getOwnPropertyNames(src)
|
||||
.filter(prop => typeof target[prop] === "undefined")
|
||||
.reduce((result, prop) => ({
|
||||
...result,
|
||||
[prop]: Object.getOwnPropertyDescriptor(src, prop),
|
||||
}), {})
|
||||
Object.defineProperties(target, props)
|
||||
}
|
||||
|
||||
global.window = window
|
||||
global.document = window.document
|
||||
global.navigator = {
|
||||
userAgent: "node.js",
|
||||
}
|
||||
copyProps(win, window) // use UI's built-in window wrapper
|
||||
copyProps(window, global)
|
||||
Reference in New Issue
Block a user