Match-id-723e7234800b3add7829cbddeacbc4e996ba02a1
This commit is contained in:
parent
84a05cf1fa
commit
25fc359310
|
@ -130,7 +130,7 @@ module.exports = {
|
|||
//setupFiles: [],
|
||||
|
||||
// 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/setupEnvironment.js')],
|
||||
setupFilesAfterEnv: [require.resolve('./scripts/__tests__/jest/deployConfiguration.js')],
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
|
|
@ -17,11 +17,11 @@ describe('useState Hook Test', () => {
|
|||
unmountComponentAtNode(container);
|
||||
container.remove();
|
||||
container = null;
|
||||
LogUtils.reset();
|
||||
LogUtils.clear();
|
||||
});
|
||||
|
||||
const Text = (props) => {
|
||||
LogUtils.injectValue(props.text);
|
||||
LogUtils.log(props.text);
|
||||
return <p>{props.text}</p>;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ describe('useState Hook Test', () => {
|
|||
it('useState的惰性初始化', () => {
|
||||
const App = forwardRef((props, ref) => {
|
||||
const [num, setNum] = useState(() => {
|
||||
LogUtils.injectValue(props.initNum);
|
||||
LogUtils.log(props.initNum);
|
||||
return props.initNum
|
||||
});
|
||||
useImperativeHandle(ref, () => ({ setNum }))
|
||||
|
|
|
@ -12,7 +12,7 @@ function runAssertion(fn) {
|
|||
|
||||
function toMatchValue(LogUtils, expectedValues) {
|
||||
return runAssertion(() => {
|
||||
const actualValues = LogUtils.getAndClearValue();
|
||||
const actualValues = LogUtils.getAndClear();
|
||||
expect(actualValues).toEqual(expectedValues);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ global.MessageChannel = function MessageChannel() {
|
|||
};
|
||||
};
|
||||
|
||||
// 使Jest感知自定义匹配器
|
||||
expect.extend({
|
||||
...require('./customMatcher'),
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
let dataArray = null;
|
||||
let isWorking = false;
|
||||
|
||||
const injectValue = (value) => {
|
||||
const log = (value) => {
|
||||
if (dataArray === null) {
|
||||
dataArray = [value];
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@ const injectValue = (value) => {
|
|||
}
|
||||
};
|
||||
|
||||
const getAndClearValue = () => {
|
||||
const getAndClear = () => {
|
||||
if (dataArray === null) {
|
||||
return [];
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ const getAndClearValue = () => {
|
|||
return values;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
const clear = () => {
|
||||
if (isWorking) {
|
||||
throw new Error('Cannot reset. There is a working task.');
|
||||
}
|
||||
dataArray = null;
|
||||
}
|
||||
|
||||
exports.reset = reset;
|
||||
exports.injectValue = injectValue;
|
||||
exports.getAndClearValue = getAndClearValue;
|
||||
exports.clear = clear;
|
||||
exports.log = log;
|
||||
exports.getAndClear = getAndClear;
|
||||
|
|
Loading…
Reference in New Issue