小编Les*_*sar的帖子

反应打字稿测试 TypeError:MutationObserver 不是构造函数

create-react上周创建了一个 React 应用程序。

我有一个简单的表单,当我单击提交时会显示一条消息。

我想测试一下,这是我创建的测试SampleForm.test.tsx

import React from "react";
import { render, fireEvent, screen, waitFor } from "@testing-library/react";
import SampleForm from "./SampleForm";
import "@testing-library/jest-dom/extend-expect"


test("renders submits form", async () => {
    const str = "THIS DIDNT DO ANYTHING";
    const { container, getByText, findByText } = render(<SampleForm />);

    fireEvent.click(screen.getByText("Submit"));

    await waitFor(() => expect(screen.getByText(str)))
});
Run Code Online (Sandbox Code Playgroud)

我在 waitFor

类型错误:MutationObserver 不是构造函数

堆栈跟踪:

at node_modules/@testing-library/dom/dist/wait-for.js:38:22
      at waitFor (node_modules/@testing-library/dom/dist/wait-for.js:31:10)
      at node_modules/@testing-library/dom/dist/wait-for.js:70:54
      at node_modules/@testing-library/react/dist/pure.js:51:22
      at node_modules/@testing-library/react/dist/act-compat.js:60:24
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:21856:12)
      at act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:929:14)
      at …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs jestjs

34
推荐指数
2
解决办法
2万
查看次数

使用 NX 仅运行一个 Jest 测试文件

nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts\n
Run Code Online (Sandbox Code Playgroud)\n

我预计只测试一个 .spec 文件。但是,错误输出显示其他 .spec 文件。

\n
$ nx run myproject:test --testFile=libs/myproject/src/lib/guards/role.guard.spec.ts \n\nFAIL   core  libs/myproject/src/lib/guards/role.guard.spec.ts\n\xe2\x97\x8f Test suite failed to run\n\n    libs/myproject/src/lib/auth/auth.service.ts:49:11 - error TS2564: Property 'sessions' has...\n\n    49   private sessions: string;\n    libs/myproject/src/lib/auth/auth.service.ts:51:11 - error TS2564...\n\n... Many more lines ...\n\nTest Suites: 1 failed, 1 total\nTests:       0 total\nSnapshots:   0 total\nTime:        6.953 s\nRan all test suites matching /libs\\\\myproject\\\\src\\\\lib\\\\guards\\\\role.guard.spec.ts/i.\n
Run Code Online (Sandbox Code Playgroud)\n

为什么要运行额外的测试,例如libs/myproject/src/lib/auth/secure.directive.spec.ts

\n

nomachine-nx jestjs angular

7
推荐指数
1
解决办法
4587
查看次数

这个标记语言是什么?...行结尾而不是结束标记

我正在尝试解析一个看起来类似于此的文档:

<PRESOL>
<DATE>1112
<YEAR>12
<AGENCY>Defense Logistics Agency
<OFFICE>DLA Acquisition Locations
<LOCATION>DLA Land and Maritime
<ZIP>43218-3990
<CLASSCOD>59
<DESC>Proposed procurement for NSN 5365013055528 SPACER,PLATE:
Line 0001 Qty 70.00  UI EA  Deliver To: ARIZONA INDUSTRIES FOR THE BLIND By: 0180 DAYS ADOThe solicitation is an RFQ and will be available at the link provided in this notice.  Hard copies of this solicitation are not available.  Digitized drawings and Military Specifications   and Standards may be retrieved, or ordered, electronically.
All responsible sources may submit …
Run Code Online (Sandbox Code Playgroud)

xml markup xml-parsing

5
推荐指数
1
解决办法
144
查看次数

如何从一个通用文件夹导入多个组件?

我的一个文件夹中有很多组件components。我怎样才能在一行中导入它们?

例如我有这个:

import FormField from "./../components/FormField";
import MultiSelect from "./../components/MultiSelect";
Run Code Online (Sandbox Code Playgroud)

但我想像这样导入它:

import {MultiSelect, FormField} from "./../components";
Run Code Online (Sandbox Code Playgroud)

这是行不通的。

reactjs

4
推荐指数
1
解决办法
868
查看次数

Sequelize Query Where 不相等和其他条件

我想让 Sequelize 中的查询 id 不相等。

这是我当前的续集查询:

return db.Area.findAll({
    where: { id: { $ne: Id },
    slug: conditions.slug }
})
Run Code Online (Sandbox Code Playgroud)

生成的 SQL 查询:

*SELECT `id`, `title`, `name`, `titleL1`, `nameL1`, `level`, `slug`, `createdAt`, `updatedAt`, `ParentId` FROM `Areas` AS `Area` 
WHERE `Area`.`id` = '[object Object]' AND `Area`.`slug` = 'Nakyal-1';*
Run Code Online (Sandbox Code Playgroud)

这部分不正确:

WHERE `Area`.`id` = '[object Object]' 
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

node.js sequelize.js

2
推荐指数
1
解决办法
1970
查看次数