在升级到jest角预设^8.3.0并尝试运行结构测试之后,在npm运行时,我看到下面的错误:
● Test suite failed to run
TypeError: Cannot read property 'createStringLiteral' of undefined
at Object.getCreateStringLiteral (../../node_modules/jest-preset-angular/build/TransformUtils.js:5:12)
at ../../node_modules/ts-jest/dist/compile
在构建这个Next.js React项目时,我得到了这个错误
Type error: 'Draggable' cannot be used as a JSX component.
Its instance type 'Draggable' is not a valid JSX element.
The types returned by 'render()' are incompatible between these types.
Type 'React.ReactNode' is
我有一个非常简单的React/类型记录应用程序,我正在努力学习如何实现测试。我用的是React测试库和Jest。这是一个非常简单的产品页面,我只想测试一下“欢迎来到我们的产品页面”这个词。
当我运行测试时,我会收到以下错误消息:The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string. Consider using the "jsdom" test environment. R
我在React + coreui开发的一个项目中工作,这个项目一直工作得很完美。然而,在上周,我在部署修改时遇到了一个令人费解的问题。
18:03:11 Creating an optimized production build...
18:04:32 Failed to compile.
18:04:32
18:04:32 /var/lib/jenkins/workspace/deploy-sandbox/src/AppRouter.tsx
18:04:32 Type error in /var/lib/jenkins/workspace/deploy-sandbox/src/
Test suite failed to run
TypeError: Cannot read property 'bind' of undefined
at jestAdapter (node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:30:56)
复制行为的步骤:
属地
"jest": "^27.0.6",
"ts-jest": "^27.0.4",
Jest配置
"jest
我有一个TypeScript项目正在利用ESLint。我有一个类,它使用作为类属性。我希望能够将缓冲区设置为构建的一部分。
example.ts
export class Example {
public myBuffer: Buffer
public constructor(myBuffer: Buffer) {
this.myBuffer = myBuffer
}
}
此块将产生以下链接错误:
5:3 error Unsafe assignment of an `any` value @typescript-eslint/n
在用VSCode中的插件进行更漂亮的配置之后,保存函数的格式在我的React+TS代码中的每个非默认导入中都添加了奇怪的value关键字。
如下所示:
import { value ApolloProvider } from '@apollo/client';
import { value BrowserRouter as Router, value Switch } from 'react-router-dom';
import Routes from './routes';
import { value client } from '
我有一个用tsx编写的页面,即使查询是useLazyQuery (所以它还没有运行),它仍然在加载时崩溃,错误为client.watchQuery cannot be called with fetchPolicy set to "standby",并且有fetchPolicy: 'no-cache'选项。它对我来说崩溃了,但对我的队友来说不是,这让我认为它可能与我的本地typescript的软件包版本有关,但我已经用我能想到的每一种方法对它进行了设置和重新设置,没有任何改进。相关代码和package.json如下。任何洞察力都会很棒。
// myfile.ts
我在GitHub操作中有一个管道,它暗示尽管它在本地工作,它还是找不到Jest。
如果我在本地运行npm run unit-tests,它可以正常工作,但是在CI中我得到以下错误:
> jest --group=unit --coverage --verbose
/tmp/unit-tests-2f311f40.sh: 1: jest: not found
name: staging-pipeline
on:
push:
tags:
- 'v*-staging'
env:
CI: true
NODE_ENV: production
jo
我目前正试图为ReactJ构建一个国家管理库。但是,一旦我将它实现到我的React项目(用create-react-app创建),它就会开始删除这个错误:
Failed to compile.
path/to/agile/dist/runtime.js 116:104
Module parse failed: Unexpected token (116:104)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader
我在这里看到过关于嘲笑默认出口的问题,但我不认为这已经被问到了:
在模拟正在测试的模块的依赖项的默认导出时,如果模块使用ES6 import语句导入依赖项,则测试套件无法运行,但是,如果模块使用require().default调用,则声明TypeError: (0 , _dependency.default) is not a function It succeeds。
在我的理解中,import module from location直接翻译成const module = require(location).default,所以我很困惑为什么会发生这种情况。我宁愿保持代码风格的一致性,而
我使用Jest制作的代码库,但我找不到一种方法来运行导入组件的简单Vue3测试。这在使用Vue-cli创建的应用程序中工作得很好,但我找不到一种方法来让Jest在使用Vue3的Vue-Vite应用程序中工作。下面是我遇到的错误 FAIL docs/homepage.spec.js
● Test suite failed to run
Vue packages version mismatch:
- vue@3.0.0 (/var/www/html/my_project_vue3_vite/node_modules/vue/index.js)
- vue
我正在为我正在制作的库编写一些测试。这不是一个项目,而是由babel从零开始构建的。我在开玩笑,我有这个问题。我看到了类似的问题,但没有像这样。在我的"test": "jest"脚本中有package.json。根文件夹中有一个__tests__目录。我的一个名为Component.js的测试文件从一些简单的导入开始:
import React from 'react';
import { MyComponent } from '../src/MyComponent.js';
当我运行npm run test时,会得到以下错误:
我试图重新组织我的TypeScript function项目的导入/导出语句,使它们更短、更简洁,基本上是通过在每个特性特定的文件夹中定义一个index.ts文件来导出资源(接口/类型/函数等)。关于那个特征的。这个解释了几乎相同的想法。
但是突然之间,jest执行会在更改后与下面的堆栈跟踪中断。所涉实体出于保密目的受到欺骗。
Test suite failed to run
TypeError: Cannot read property 'FooBarEnum' of undefined
at Object.FooBarEnum (src/feat
Pact依赖于一个名为make-error-cause的包。在它的index.js中,它声明了一个方法,然后紧接着声明了一个同名的var。
Jest/Typescript不喜欢这样。当使用Jest运行时,我们所做的任何事情都不会允许我们的测试运行,我们不断地得到这个错误:
SyntaxError: /Users/user1234/Documents/Workspace/aws_stack/node_modules/make-error-cause/dist/index.js: Identifier 'makeErrorCause' has already been declar