我是新的类型抄本,并希望实现与Jest单元测试。我安装了Jest,当我运行它时收到一个错误,我简化了这个示例的代码,它继续失败:
FAIL src\__tests__\validateSender.ts
https validation
ReferenceError: validateSender is not defined
at Object.<anonymous>.test (src/__tests__/validateSender.ts:10:10)
at process._tickCallback (internal/process/next_tick.js
由于某些原因,当试图重新运行以前通过的测试套件时,我现在得到一个类型记录构建错误error TS2304: Cannot find name 'setTimeout'。
我认为这个问题是在最近的打字稿版本中出现的,从那以后就没有改变过。然而,我没有看到很多setTimeout没有被定义的例子,所以我不得不知道我需要改变什么。
有人知道我能做些什么来减轻吗?
误差
完全错误..。
FAIL test/core/partition.test.ts
● Test suite failed to run
test/core/partition.test.ts:86:36
我刚开始了一个与Webpack合作的新项目。在为应用程序服务时,我总是会遇到同样的错误。
错误:模块构建失败:'C:\workwork\apol2\apol2\node_modules\webpack\buildin\global.js‘::没有这样的文件或目录,打开对象处的。在webpack_require (引导73c6a5b3e608efed68ac:19)(scheduler.development.js:699) at scheduler.development.js:699(引导73c6a5b3e608efed68ac:19)(index.js:6) at Object。(
我正试着用说笑的马戏团跑步者来说笑。在没有runner的情况下,测试可以正确执行,但只要我添加下面这行: 'testRunner': 'jest-circus/runner', 添加到我的jest配置。我看到以下错误: FAIL migration.test.js
● Test suite failed to run
TypeError: Expected throat size to be a number but got undefined
at throat (node_modules/throat/index.js:34:13)
我使用的是react-ga v2.5.7,为此我更新了react-redux v7.0.2,我使用的是jest v24.7.1 我在testMode中设置了react-ga,但它在我的jest.setup.js中被模拟了。但是每次我运行我的测试时,我总是遇到同样的问题,大多数测试都因为一些奇怪的原因而失败: Test suite failed to run
Cannot find module '@icons/material/CheckIcon' from 'SwatchesColor.js'
However, Jest was able
我有无服务器应用程序(节点:14.19.1-斗牛眼-苗条),有将近400个测试。主要是使用进行功能测试。问题是Bitbucket管道有时会在消息中失败:
thrown: "Exceeded timeout of 10000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
这样做的坏处在于不能在本地机器上重现的问题。9/10跑是绿色的。同样,在Bitbucket管道上,并不是每次运行都失败,也不是在同一个测试
Jest cli突然停止工作,所有测试都失败,并显示: Cannot find module 'babel-preset-env' from '/PATH'
- Did you mean "@babel/env"? 我确信使用babel 6的模块与我使用babel 7的项目之间存在某种不兼容,但我不确定我该如何解决。 这是package.json {
"name": "testing101",
"version": "1.0.0",
"descripti
当我在没有标志--runInBand或maxWorkers大于1的情况下运行测试时,它们会失败。但是,如果我提供了标志或更改了maxWorkers,那么一切都会过去。
失败场景:复制步骤:
npx jest --clearCache
npx jest
其结果应如下:
成功场景:复制步骤:
npx jest --clearCache
npx jest --runInBand
其结果应如下:
无论标志/maxWorkers如何,我都希望所有的测试都能通过。
我有Jest测试,这些测试运行在Neo4j数据库上,有时在CircleCI上失败。它们中所有25+的错误消息是:
thrown: "Exceeded timeout of 5000 ms for a hook.
@*******api: Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
由于它们有时会失败,比如每25次运行一次,我想知道jest.setTimeout是否会解决这个问题。通过设置jest.setTimeout(10)
在bitbucket管道中使用Jest,它找不到测试,因此失败了,出现了以下错误:
+ npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /opt/atlassian/pipelines/agent/build
12 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 2 matches
testPathIgnoreP
我正在尝试遵循https://jestjs.io/docs/en/api中关于导入全局变量的建议,即: However, if you prefer explicit imports, you can do import {describe, expect, it} from '@jest/globals'. 不过,它不起作用。我在两个测试文件的顶部添加了import,当我运行jest时,两个测试套件都失败,并显示消息"Do not import @ Jest /globals not of the Jest test environment“。 我还在eslint
我对单元测试很陌生,我刚刚开始为我的react项目编写单元测试。我的项目是使用创建-反应-应用程序创建的,我已经安装了所需的测试库,如酶、酶适配器-Reacti-16和jest-酶。
我在src目录中创建了一个新文件setupTests.js,并添加了酶配置。
当我试图使用命令npm test运行单元测试时,我收到了下面的错误,因此我的测试失败了。
src/App.test.js
● Test suite failed to run
Cannot find module '@babel/polyfill/lib/noConflict' from 'index.js
我正在为一个客户开发一个新项目,并被要求将create-react-app (react-scripts)从v.2.0.5更新到v.4.0.3。我这样做了,很多单元测试都失败了。我回顾了整个项目,并隔离了从react-scripts 3.4.4到4.0.0的更新。 基本上,我看到的主要错误似乎适用于针对async/await方法运行的任何测试。Jest报告测试超时,但这些测试只是超时,因为它们失败了。它们在早期版本的react-scripts (以及我猜的早期版本的Jest )上都通过了,没有问题。 thrown: "Exceeded timeout of 5000 ms for a
我正在使用被篡改的NestJS,并且正在使用Jest (ts-jest)运行测试。我的一个测试超过了5000 ms的超时,导致整个测试套件失败,但是命令行输出非常通用(见下文)。
● Test suite failed to run
nest-test |
nest-test | Timeout - Async callback was not invoked within the 50000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was no