微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何设置 Github Action 工作流以在 Windows/IE11 虚拟机上测试 React App? 发生了什么失败的地方问题

如何解决如何设置 Github Action 工作流以在 Windows/IE11 虚拟机上测试 React App? 发生了什么失败的地方问题

我正在设置 Github Action 工作流,以在 testcafe (Internet Explorer) 上使用 IE11 测试我的应用。

name: Tests
on:
  push:
    branches:
      - master
  pull_request:
    types: [opened,reopened,synchronize,ready_for_review]

jobs:
  test-e2e-ie11:
    name: Run Tests for IE11
    runs-on: windows-2016
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install Ddependencies
        run: yarn install
      - name: End-to-end testing
        uses: DevExpress/testcafe-action@latest
        with:
          args: "ie testcafe --app-init-delay 60000 --app node scripts/start.js -- --deploy=local"
        env:
          NODE_ENV: development

发生了什么

安装依赖项有点长但正确发生:

Install Ddependencies
info There appears to be trouble with your network connection. retrying...
warning mini-css-extract-plugin@0.4.5: Invalid bin field for "mini-css-extract-plugin".
warning file-loader@2.0.0: Invalid bin field for "file-loader".
warning url-loader@1.1.2: Invalid bin field for "url-loader".
warning url-loader@1.1.1: Invalid bin field for "url-loader".
info fsevents@2.3.2: The platform "win32" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and Failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and Failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
warning " > cypress-iframe@1.0.1" has unmet peer dependency "@types/cypress@^1.1.0".
warning " > cypress-image-snapshot@4.0.1" has incorrect peer dependency "cypress@^4.5.0".
warning "cypress-image-snapshot > jest-image-snapshot@4.2.0" has incorrect peer dependency "jest@>=20 <=26".
warning " > storybook-addon-styled-component-theme@1.1.0" has incorrect peer dependency "@storybook/addons@^3.4.8".
warning " > storybook-addon-styled-component-theme@1.1.0" has incorrect peer dependency "styled-components@^3.3.2".
warning " > storybook-styled-components@1.1.2" has incorrect peer dependency "@storybook/addons@^3.3.0".
[5/5] Building fresh packages...
$ husky install
husky - Git hooks installed
Done in 468.00s.

失败的地方

testcafe 行为很奇怪恕我直言,有很多警告

Run DevExpress/testcafe-action@latest
  with:
    args: ie testcafe --app-init-delay 60000 --app node scripts/start.js -- --deploy=local
    version: latest
    skip-install: false
  env:
    NODE_ENV: development
VERSION: latest
BRANCH: not specified
COMMIT: not specified
SKIP INSTALL: false
Installing testcafe from npm...
npm WARN deprecated…
npm WARN deprecated…
…
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\rimraf.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\rimraf
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\rimraf as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\rimraf
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\semver.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\semver
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\semver as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\semver
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\browserslist.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\browserslist
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\browserslist as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\browserslist
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\mkdirp.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\mkdirp
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\mkdirp as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\mkdirp
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\json5.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\json5
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\json5 as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\json5
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\jest.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\jest-cli
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\jest as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\jest-cli
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\detect.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\detect-port
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\detect-port.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\detect-port
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\detect as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\detect-port
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\detect-port as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\detect-port
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\acorn.cmd as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\acorn
npm WARN rm not removing D:\a\webchat-v2\webchat-v2\node_modules\.bin\acorn as it wasn't installed by D:\a\webchat-v2\webchat-v2\node_modules\acorn
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^2.3.2 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"x64"})
npm WARN render-fragment@0.1.1 requires a peer of prop-types@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-split-pane@0.1.92 requires a peer of react@^16.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN react-split-pane@0.1.92 requires a peer of react-dom@^16.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN react-color@2.19.3 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN @icons/material@0.2.4 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN @storybook/core@4.1.18 requires a peer of react@* but none is installed. You must install peer dependencies yourself.
npm WARN @storybook/core@4.1.18 requires a peer of react-dom@* but none is installed. You must install peer dependencies yourself.
npm WARN @storybook/react-komposer@2.0.5 requires a peer of react@^0.14.7 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-fuzzy@0.5.2 requires a peer of react@^0.14.7 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-modal@3.14.3 requires a peer of react@^0.14.0 || ^15.0.0 || ^16 || ^17 but none is installed. You must install peer dependencies yourself.
npm WARN react-modal@3.14.3 requires a peer of react-dom@^0.14.0 || ^15.0.0 || ^16 || ^17 but none is installed. You must install peer dependencies yourself.
npm WARN react-treebeard@3.1.0 requires a peer of react@^15.5.4 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-treebeard@3.1.0 requires a peer of react-dom@^15.5.4 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @storybook/react-simple-di@1.3.0 requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @storybook/react-stubber@1.0.1 requires a peer of react@^0.14.7 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN veLocity-react@1.4.3 requires a peer of react@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN veLocity-react@1.4.3 requires a peer of react-dom@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-transition-group@2.9.0 requires a peer of react@>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-transition-group@2.9.0 requires a peer of react-dom@>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN jest-image-snapshot@4.2.0 requires a peer of jest@>=20 <=26 but none is installed. You must install peer dependencies yourself.
npm WARN react-ga@2.7.0 requires a peer of prop-types@^15.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-ga@2.7.0 requires a peer of react@^15.6.2 || ^16.0 but none is installed. You must install peer dependencies yourself.

然后在尝试启动我的应用程序服务器以便 testcafe 可以访问它时,它无法找到 dotenv,我的 packages.json 中存在一个包:

Running testcafe...
process.env.DEPLOYMENT_ENV local
ERROR Cannot prepare tests due to the following error:

Error: Cannot find module 'dotenv'
Require stack:
- D:\a\webchat-v2\webchat-v2\config\env.js
- D:\a\webchat-v2\webchat-v2\scripts\start.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\compiler\test-file\formats\es-next\compiler.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\compiler\compilers.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\compiler\index.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\runner\bootstrapper.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\runner\index.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\testcafe.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\index.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\cli\cli.js
- D:\a\webchat-v2\webchat-v2\node_modules\testcafe\lib\cli\index.js
    at forEach (D:\a\webchat-v2\webchat-v2\config\env.js:34:7)
    at Object.<anonymous> (D:\a\webchat-v2\webchat-v2\config\env.js:31:13)
    at Object.<anonymous> (D:\a\webchat-v2\webchat-v2\scripts\start.js:12:1)

Type "testcafe -h" for help.
child_process.js:660
    throw err;
    ^

Error: Command Failed: npx testcafe ie testcafe --app-init-delay 60000 --app node scripts/start.js -- --deploy=local
    at checkExecSyncError (child_process.js:621:11)
    at execSync (child_process.js:657:15)
    at Object.<anonymous> (D:\a\_actions\DevExpress\testcafe-action\latest\index.js:64:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11 {
  status: 1,signal: null,output: [ null,null,null ],pid: 2220,stdout: null,stderr: null
}

问题

我的工作流程中缺少什么,以便我可以针对我的 React 开发应用运行 testcafe 测试?

解决方法

您在测试运行命令的参数中有错误:

args: "ie testcafe --app-init-delay 60000 --app node scripts/start.js -- --deploy=local"

我想这行应该是这样的:

args: "ie --app-init-delay 60000 --app \"node scripts/start.js --deploy=local\""

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。