Match-id-29274c466e8ff01f1547e591ff136f857514db5f

This commit is contained in:
* 2022-03-15 18:01:45 +08:00 committed by *
parent 2100ebcb57
commit 80690326c8
5 changed files with 18 additions and 13 deletions

View File

@ -58,15 +58,7 @@ module.exports = {
// globalTeardown: undefined, // globalTeardown: undefined,
// A set of global variables that need to be available in all test environments // A set of global variables that need to be available in all test environments
globals: { // globals: {},
//'isDev': process.env.NODE_ENV === 'development',
'MessageChannel': function MessageChannel() {
this.port1 = {};
this.port2 = {
postMessage() {}
};
}
},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%", // maxWorkers: "50%",
@ -127,7 +119,7 @@ module.exports = {
// runner: "jest-runner", // runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test // The paths to modules that run some code to configure or set up the testing environment before each test
//setupFiles: [], setupFiles: [require.resolve('./scripts/__tests__/jest/jestEnvironment.js')],
// A list of paths to modules that run some code to configure or set up the testing framework before each test // A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [require.resolve('./scripts/__tests__/jest/jestSetting.js')], setupFilesAfterEnv: [require.resolve('./scripts/__tests__/jest/jestSetting.js')],

View File

@ -6,7 +6,13 @@ import { act } from '../../jest/customMatcher';
import Text from '../../jest/Text'; import Text from '../../jest/Text';
describe('useEffect Hook Test', () => { describe('useEffect Hook Test', () => {
const { useEffect, useLayoutEffect, useState, memo, forwardRef } = React; const {
useEffect,
useLayoutEffect,
useState,
memo,
forwardRef
} = React;
it('简单使用useEffect', () => { it('简单使用useEffect', () => {
const App = () => { const App = () => {

View File

@ -2,6 +2,7 @@
import * as React from '../../../../libs/horizon/src/external/Horizon'; import * as React from '../../../../libs/horizon/src/external/Horizon';
import * as HorizonDOM from '../../../../libs/horizon/src/dom/DOMExternal'; import * as HorizonDOM from '../../../../libs/horizon/src/dom/DOMExternal';
import * as LogUtils from '../../jest/logUtils'; import * as LogUtils from '../../jest/logUtils';
import { act } from '../../jest/customMatcher';
import Text from '../../jest/Text'; import Text from '../../jest/Text';
describe('useImperativeHandle Hook Test', () => { describe('useImperativeHandle Hook Test', () => {
@ -10,6 +11,7 @@ describe('useImperativeHandle Hook Test', () => {
useImperativeHandle, useImperativeHandle,
forwardRef forwardRef
} = React; } = React;
const { unmountComponentAtNode } = HorizonDOM;
it('测试useImperativeHandle', () => { it('测试useImperativeHandle', () => {

View File

@ -0,0 +1,6 @@
global.MessageChannel = function MessageChannel() {
this.port1 = {};
this.port2 = {
postMessage() { }
};
};

View File

@ -2,7 +2,6 @@ import { unmountComponentAtNode } from '../../../libs/horizon/src/dom/DOMExterna
import * as LogUtils from '../jest/logUtils'; import * as LogUtils from '../jest/logUtils';
global.isDev = process.env.NODE_ENV === 'development'; global.isDev = process.env.NODE_ENV === 'development';
global.container = null; global.container = null;
global.beforeEach(() => { global.beforeEach(() => {
LogUtils.clear(); LogUtils.clear();