对于create-react-app,我__test__在与src
运行npm test项目文件夹后,我收到以下错误
我该如何解决这个问题,以便我可以运行我的测试?
jenkins@VBOX:dashboard$ npm test
> react-scripts test --env=jsdom
Determining test suites to run...fs.js:1236
throw error;
^
Error: watch /home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/babel-jest/node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument/node_modules/babel-types/node_modules/babel-runtime/node_modules/core-js/fn/symbol ENOSPC
at exports._errnoException (util.js:907:11)
at FSWatcher.start (fs.js:1234:19)
at Object.fs.watch (fs.js:1262:11)
at NodeWatcher.watchdir (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/src/node_watcher.js:144:20)
at Walker.<anonymous> (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/src/node_watcher.js:353:12)
at emitTwo (events.js:87:13)
at Walker.emit (events.js:172:7)
at /home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/sane/node_modules/walker/lib/walker.js:69:16
at go$readdir$cb (/home/jenkins/dev/git-stash/dashboard/node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/node_modules/graceful-fs/graceful-fs.js:149:14)
at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR! Test failed. See above for more details.
Run Code Online (Sandbox Code Playgroud) 我正在我的create-react-app应用程序上设置 Twitter oauth ,方法是axios在前端使用辅助函数(via )passport在我的后端启动oauth 过程。我目前正在开发中,所以我在端口上托管我的快速服务器,在端口上托管我的3001前端,前端3000有一个代理到端口3001.我已经通过corsnpm 包设置了 CORS 权限。
无论我尝试哪种配置,我都无法完成 Twitter OAuth 流程。我试过切换端口,保持相同的端口;我试过用express-http-proxy.
我在回调函数和初始 api 调用中都使用了http://127.0.0.1而不是localhost,尝试了端口3000和3001.
我现在不确定我哪里出错了,或者我是否需要放弃passport-twitter其他解决方案。
在每种情况下,我都会收到以下错误:
Failed to load https://api.twitter.com/oauth/authenticate?
oauth_token=alphanumericcoderedactedherebyme: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'http://localhost:3000' is
therefore not allowed access.
Run Code Online (Sandbox Code Playgroud)
根据我尝试的配置,我将 origin 设为nullorhttp://localhost:3001或http://127.0.0.1。
请注意,由于其他原因,例如连接到Yelp Fusion API. 此外,我使用中间件来记录我的会话数据,我可以看到我成功地获取 …
我不记得在哪里,我看到一个路由器使用这样的 404 组件
<Route component={404}/>
Run Code Online (Sandbox Code Playgroud)
我试过创建一个组件
const 404 = props => {
return (<h1>This is a 404 page!</h1>)
}
Run Code Online (Sandbox Code Playgroud)
它甚至不编译。我正在使用 create-react-app 和 React Router。
我正在尝试对使用装饰器和 Typescript 与 Create React App v2.1.0 一起使用的 React 应用程序进行测试
我知道装饰器不受官方支持。
由于React App Rewired和@babel/plugin-proposal-decorators ,我可以很好地运行应用程序。
我遇到的问题是在运行测试时启用装饰器支持。
我的 npmtest脚本是:"test": "react-app-rewired test --env=jsdom --runInBand"
测试失败:
'decorators' 插件需要一个 'decoratorsBeforeExport' 选项,其值必须是布尔值。如果您从 Babylon/Babel 6 迁移或想使用旧的装饰器提案,则应使用“decorators-legacy”插件而不是“decorators”
我试图添加一个.babelrc文件,其中包含以下内容:
{
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]]
}
Run Code Online (Sandbox Code Playgroud)
但被击中:
不能同时使用装饰器和装饰器遗留插件
我正在使用 create-react-app,它在我的本地运行良好,没有任何问题。当我将其部署在 IBM Cloud 上时,登录后,当我刷新页面时,它会给出404 未找到错误之前工作正常,不确定发生了什么。
我看到了很多相关的问题,我试图解决但没有成功的事情如下
1. 创建一个static.json
{
"root": "build/",
"routes": {
"/**": "index.html"
}
}
Run Code Online (Sandbox Code Playgroud)
2.我有这个设置
devServer: {
historyApiFallback: true,
contentBase: './',
hot: true
},
Run Code Online (Sandbox Code Playgroud)
3.我尝试添加路由器,但没有成功
import React, { Component } from 'react';
import styled from 'styled-components';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
class App extends Component {
render() {
return (
<>
<Router>
<Switch>
<Route exact path="/" component={SignUp} />
<Route path="/some" component={Some} />
</Switch>
</Router>
</>
);
}
}
export …Run Code Online (Sandbox Code Playgroud) 我可以使用默认端口 3000 启动 react js。但是,当我将端口自定义为 4200 时"start": "PORT=4200 react-scripts start"(只是在 package.json 中更改),我无法启动 react js 应用程序。
'PORT' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo-app@0.1.0 start: `PORT=4200 react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional lo
ging output above. …Run Code Online (Sandbox Code Playgroud) 当尝试创建反应应用程序时,出现以下错误。
Creating a new React app in /home/sabin/development/react/complete-guide.
warning You are using Node "13.0.0-nightly20190802452b393c1f" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.17.3
warning You are using Node "13.0.0-nightly20190802452b393c1f" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || …Run Code Online (Sandbox Code Playgroud) 我试图将指向我的投资组合的链接发布到linkedin,它总是显示“使用react app创建的网站”作为描述,这绝对不会让它看起来很专业。它部署在我的域中,但有什么方法可以摆脱域链接上的所有 create-react-app 默认内容?
我正在尝试将 Jest 用于新的 CRA 项目,但在尝试使用该findByText功能时遇到了问题。我安装了:
yarn add -D jest-environment-jsdom-sixteen
Run Code Online (Sandbox Code Playgroud)
并使用react-scripts test --env=jest-environment-jsdom-sixteen. 如果我在这里阅读这些问题时遇到了这个解决方案,它会很好地工作:
但是,我也在使用来自 VS 代码的 Jest 插件并且测试没有通过它。我尝试按照文档中的jest.config.js建议执行此操作:
module.exports = {
testEnvironment: 'jest-environment-jsdom-sixteen',
};
Run Code Online (Sandbox Code Playgroud)
但它仍然不起作用。
提前致谢。
create-react-app ×10
reactjs ×9
javascript ×3
jestjs ×3
node.js ×2
cors ×1
ibm-cloud ×1
nginx ×1
npm ×1
npx ×1
passport.js ×1
react-native ×1
react-router ×1
typescript ×1