- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
运行 npm run test
命令时出现错误。
user@user-ps:~/documents/driver-app$ npm run test
> driverApp@0.0.1 test /home/user/documents/driver-app
> jest
FAIL __tests__/App-test.tsx
● Test suite failed to run
Cannot find module 'react-dom' from 'mobxreact.cjs.development.js'
However, Jest was able to find:
'../App.tsx'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (node_modules/mobx-react/dist/mobxreact.cjs.development.js:10:16)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 9.031s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! driverApp@0.0.1 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the driverApp@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-02-27T07_58_19_815Z-debug.log
这是我的测试App-test.tsx
文件
/**
* @format
*/
import 'react-native';
import React from 'react';
import { App } from './../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
renderer.create(<App />);
});
我找到了解决问题的信息,但对我没有帮助。
https://github.com/mobxjs/mobx-react/issues/764#issuecomment-524507782
package.json
文件中的jest
配置
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@?react-navigation|@?react-native-community)"
],
"setupFiles": [
"./node_modules/react-native-gesture-handler/jestSetup.js"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
为什么我的测试没有通过?
最佳答案
我只是简单地将 react-dom
添加到我的开发依赖项中:
yarn add react-dom --dev
关于react-native - 无法从 'react-dom' 找到模块 'mobxreact.cjs.development.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60428975/
/~/@ReMix-Run/Router/dist/router.cjs.js模块分析失败:/HOME/sharib/Desktop/Full Stack Developer Tutorial/MER
在 CJS 模块中,我会使用 export 和 var plugin = require('plugin'); 导出/导入 在 ES6 模块中,我会使用 export 和 import * as pl
我有一个组件库,它将发布到 npm 以供 razzle 应用程序使用。我想要对最佳实践发表意见的主要问题是,这些包应该用 cjs 还是 esm 构建,每个的缺点是什么? 我可以只构建到 cjs 吗?
我用 package.json 安装了 reactjs 和 react-dom "dependencies": { "bootstrap": "^v4.1.1",
我的Rollup项目是这样的... // rollup.config.js import pkg from "./package.json"; import {getRollupServerConfi
正如标题所说,有一个 react/cjs/react.development有时在自动完成正常的 React 元素(如 useState)时添加的库. 我曾经忽略它并选择 React,但它突然在生产中
我想运行我的应用程序,但突然收到此错误。为什么? 这就是我工作的订单的样子。 ./ ├─ app.js ├─ .env ├─ .gitignore ├─ node modules/ │ └─ ...
当我输入任何 npm cmd 时遇到问题,它显示 内部/modules/cjs/loader.js:584 操作系统:Windows 10 64位 我该如何解决这个问题? internal/modul
一开始,Javascript 没有办法导入/导出模块。这是个问题。想象一下,在一个文件中编写您的应用程序 - 这将是一场噩梦! 然后,比我聪明得多的人试图为 Javascript 添加模块化。其中
我在 Github 上有一个忽略 node_modules 文件夹的项目,因此我更改了计算机并再次克隆了存储库。 我用了npm-install-all安装所有 Node 依赖项,它曾经可以工作。 但是
在我的项目文件夹中执行 yarn install 并出现以下错误。 internal/modules/cjs/loader.js:800 throw err; ^ Error: Cannot find
我遇到了运行 npm start 的问题(我在我的 Angular 项目中附上了错误的截图)。 当我使用 ng serve 运行项目时,一切正常。 我尝试了几种方法来解决此问题,但均未成功。 这是我的
当我运行 npm 命令来运行 umi 应用项目时遇到错误。这是我运行代码时看到的错误。 我尝试检查 Node 模块中的 loader.js 文件,但未能找到它。 internal/modules/cj
我收到以下控制台错误。错误:找不到模块 这是我在控制台中遇到的完整错误。我该怎么办? internal/modules/cjs/loader.js:582 throw err; ^ E
运行 npm run test 命令时出现错误。 user@user-ps:~/documents/driver-app$ npm run test > driverApp@0.0.1 test /h
我正在尝试使用 React 制作一个电子商务网站。它工作得很好,但是在我安装 redux 和 react-redux 之后,我收到了这个错误: Uncaught Error: Module build
我正在构建一个 React 应用程序,并在文件中导入了一个 slider 然后我得到了一个 css-loader,我也在使用 webpack 这是我的 slider - import React, {
已成功设置 jest/esm,但偶尔会发布一个模块,同时指定 main key (用于 commonjs)和 module package.json 中的 key (对于 ESM) .这会导致 Jes
我正在尝试快速启动 ava electron webpack 和三个,但在该过程中出现了问题。 这里是项目的存储库: https://github.com/etiennerin/ecsy-three-
我下载了我的类(class)react项目,进入了该项目,安装了依赖项,并尝试运行npm start。我收到这个讨厌的错误: PS C:\Users\Marcin & Joanna\Desktop\r
我是一名优秀的程序员,十分优秀!