gpt4 book ai didi

reactjs - 您的测试套件必须至少包含一项测试

转载 作者:行者123 更新时间:2023-12-03 15:09:27 26 4
gpt4 key购买 nike

我今天在我的项目中更新了一些依赖项,但它进行得非常顺利。现在,当我要插入它时,我开始了我的测试。和繁荣。他们都抛出:
Your test suite must contain at least one test.
我的包裹:

"jest": "23.1.0",
"jest-enzyme": "^6.0.1",
"jest-webpack-alias": "^3.3.3",
"jsdom": "^11.2.0",
"jsdom-global": "^3.0.2",
"enzyme": "3.3.0",
"enzyme-adapter-react-16": "^1.1.0",
"enzyme-to-json": "3.3.4",

这就是我的示例测试文件的样子:

/shared/components/App/MyRoute/__tests__/MyRoute.test.js
/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { shallow } from 'enzyme';
import { ContactsRoute } from '../Route';

describe('<ContactsRoute />', () => {
test('renders', () => {
const wrapper = shallow(<ContactsRoute t={key => key} />);
expect(wrapper).toMatchSnapshot();
});
});

我不知道他们为什么突然停止运行?

编辑 - 添加我的笑话配置
  "jest": {
"collectCoverageFrom": [
"shared/**/*.{js,jsx}"
],
"globals": {
"JWT_SECRET": "local",
"IS_TEST": "true"
},
"snapshotSerializers": [
"<rootDir>/node_modules/enzyme-to-json/serializer"
],
"testPathIgnorePatterns": [
"<rootDir>/(build|internal|node_modules|flow-typed|public|shared/services)/"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/_test_config_/mocks/fileMock.js"
},
"testURL": "http://localhost:3005",
"transform": {
".": "<rootDir>/_test_config_/preprocessors/webpackAlias.js",
"^.+\\.css$": "<rootDir>/_test_config_/preprocessors/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/_test_config_/preprocessors/fileTransform.js"
},
"setupFiles": [
"<rootDir>/_test_config_/preprocessors/polyfills.js"
],
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js"
},

最佳答案

确保未导入 describe/it/expect 变量
就我而言,IDE( VSCode )会自动导入变量 describe从另一个图书馆。

关于reactjs - 您的测试套件必须至少包含一项测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50843511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com