Jon*_*man 5 webstorm typescript reactjs cypress
我在 TypeScript 和 WebStorm 中使用 Cypress。我已经在项目 A1 上工作了几个星期,我添加了 Cypress,我将 TS 添加到 Cypress,然后事情开始变得有点有趣,包括在 Cypress 和我的 src 中将 js 文件与 ts 文件一起添加文件夹。(tsx 文件没有这样做,只有 ts)
\n所以我重新启动了该项目:我创建了一个全新的 Create React App 项目 A2,并开始将文件从 A1 一个接一个(或一个文件夹一个文件夹)拖动到 A2。我通过在 A2cypress open中没有 cypress 文件时运行来将 Cypress 文件添加到 A2,这导致 Cypress 添加其文件。然后我从 A1 添加了测试(将代码复制到新文件中,而不是复制文件)并设置各种配置文件和内容,例如:
然后我删除了A1项目中的所有文件,并从A2中拖入所有文件(减去文件node_modules夹),然后运行yarn install.
一切正常,除了 Cypress 文件夹仍然在 ts 文件旁边创建 js 文件。
\n很难确定发生这种情况的实际时刻:我写了这篇文章并放弃了它,因为事情似乎运行良好。但几个小时后我发现 js 文件又回来了!仅在 Cypress 文件夹中,包括 Cypress 文件夹中的所有 ts 文件(/integration、/plugins 等)。
\n这是一些 tsconfig:
\ncypress/tsconfig.json
{\n "compilerOptions": {\n "target": "es5",\n "lib": ["es5", "dom"],\n "types": ["cypress"]\n },\n "include": [\n "**/*.ts", "**/*.d.ts"\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n<project_root>/tsconfig.json
{\n "compilerOptions": {\n "target": "es5",\n "lib": [\n "dom",\n "dom.iterable",\n "esnext"\n ],\n "allowJs": true,\n "skipLibCheck": true,\n "esModuleInterop": true,\n "allowSyntheticDefaultImports": true,\n "strict": true,\n "forceConsistentCasingInFileNames": true,\n "module": "esnext",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "isolatedModules": true,\n "noEmit": true,\n "jsx": "react"\n },\n "include": [\n "src"\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n哦不,现在突然间它在我的src文件夹中从 ts 中生成了 js 文件!
当我删除所有这些额外的 js 文件(在 src 文件夹中,在运行的应用程序中生成警告)时,我还会从 WebStorm 收到此类警告:
\n\n\n哎呀!出了些问题!:( ESLint: 6.7.2。ESLint 找不到插件“eslint-plugin-import”。(从目录“/Users/ 加载为 Node 模块时找不到包“eslint-plugin-import” tuzmacbookpro2017/dev/Sunrise/IVD”。)该插件可能未正确安装。请尝试运行以下命令重新安装: npm install eslint-plugin-import@latest --save-dev 插件“eslint -plugin-import”是从“nginx/front_end/package.json \xc2\xbb eslint-config-react-app”中的配置文件引用的。如果您仍然无法弄清楚问题,请停止通过https: //gitter.im/eslint/eslint与团队聊天。
\n
不过,React 服务器、cypress 服务器和 runner 看起来都很高兴。
\n帮助!这些 js 文件是怎么回事?(我知道 TS 将 ts 转译为 js 或其他什么,但通常文件实际上不会像这样显示)
\n小智 1
您可以将配置文件
false值传递到下一个字段:
(当然,或者只是为了您需要的字段。)
文档: https ://docs.cypress.io/guides/references/configuration.html#Folders-Files
| 归档时间: |
|
| 查看次数: |
1492 次 |
| 最近记录: |