Angular “码头工人”;无法执行e2e脚本";

Angular “码头工人”;无法执行e2e脚本";,angular,docker,e2e-testing,Angular,Docker,E2e Testing,我有一个关于Angular 9的项目。我写了测试,现在我需要从docker开始。我注意到本地测试通过了 My progrator.conf: // @ts-check // Protractor configuration file, see link for more information // https://github.com/angular/protractor/blob/master/lib/config.ts const { browser } = require('protr

我有一个关于Angular 9的项目。我写了测试,现在我需要从docker开始。我注意到本地测试通过了

My progrator.conf:

// @ts-check
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const { browser } = require('protractor');
const { SpecReporter } = require('jasmine-spec-reporter');
const fs = require('fs');
const filePath = (`${process.cwd()}\\e2e\\downl_docs`).replace(/\\/g, '/');
const path = require('path');

/**
 * @type { import("protractor").Config }
 */
exports.config = {
  allScriptsTimeout: 30000,
  specs: [
    'src/suites/authorization/*.e2e-spec.ts',
    'src/suites/user/*.e2e-spec.ts',
    'src/suites/group/group_subs.e2e-spec.ts',
    'src/suites/group/group.e2e-spec.ts',
    'src/suites/group/group_load_docs.e2e-spec.ts',
    'src/suites/group/group_edit.e2e-spec.ts',
    'src/suites/tests/crud_tests.e2e-spec.ts',
    'src/suites/tests/crud_questions.e2e-spec.ts',
    'src/suites/tests/crud_answers.e2e-spec.ts',
    'src/suites/tests/check_res_test.e2e-spec.ts',
    'src/suites/tests/passing_test.e2e-spec.ts',
    'src/suites/search/search.e2e-spec.ts',
    'src/suites/chat/chat.e2e-spec.ts',
    'src/suites/chat/chat_send.e2e-spec.ts',
  ],
    capabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--headless', '--disable-gpu', '--window-size=800,600'],
      prefs: {
        download: {
          prompt_for_download: false,
          default_directory: `${process.cwd()}\\e2e\\downl_docs`,
          directory_upgrade: true
        }
      }
    },
  },
  chromeOnly: true,
  suites: {
    auth: 'src/suites/authorization/*.e2e-spec.ts',
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 90000,
    print: function () { }
  },
  onPrepare() {
    const directory = 'test';

    fs.readdir(filePath, (err, files) => {
      if (err) throw err;
      if (files.length > 0) {
        for (const file of files) {
          fs.unlink(path.join(filePath, file), err => {
            if (err) throw err;
          });
        }
      }
    });
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

我的Docker文件:

FROM trion/ng-cli-e2e
WORKDIR /app
COPY . .
RUN npm install
CMD npm run e2e
My docker-compose.yml:

version: '3.4'

services:
  client:
    image: ${DOCKER_REGISTRY-}client
    build:
      context: ../../../client/UmkMainClient/
      dockerfile: ./Test.Dockerfile
    ports:
      - "4200:4200"
我的终端日志:

client_1  | 
client_1  | > umk@0.0.0 e2e /app
client_1  | > ng e2e
client_1  |
client_1  | [11:04:25] I/file_manager - creating folder /app/node_modules/protractor/node_modules/webdriver-manager/selenium
client_1  | [11:04:25] I/config_source - curl -o/app/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
client_1  | [11:04:26] I/downloader - curl -o/app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.138.zip https://chromedriver.storage.googleapis.com/81.0.4044.69/chromedriver_linux64.zip
client_1  | [11:04:26] I/update - chromedriver: unzipping chromedriver_81.0.4044.138.zip
client_1  | [11:04:27] I/update - chromedriver: setting permissions to 0755 for /app/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_81.0.4044.138
client_1  | Compiling @angular/core : es2015 as esm2015
...
client_1  | 
client_1  | chunk {assets/syncfusion/base/material} material.css, material.css.map (assets/syncfusion/base/material) 153 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/buttons/material} material.css, material.css.map (assets/syncfusion/buttons/material) 158 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/dropdowns/material} material.css, material.css.map (assets/syncfusion/dropdowns/material) 94.4 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/inputs/material} material.css, material.css.map (assets/syncfusion/inputs/material) 813 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/navigations/material} material.css, material.css.map (assets/syncfusion/navigations/material) 230 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/notifications/material} material.css, material.css.map (assets/syncfusion/notifications/material) 16.5 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/pdfviewer/material} material.css, material.css.map (assets/syncfusion/pdfviewer/material) 58.4 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/popups/material} material.css, material.css.map (assets/syncfusion/popups/material) 16.1 kB [initial] [rendered]
client_1  | chunk {assets/syncfusion/splitbuttons/material} material.css, material.css.map (assets/syncfusion/splitbuttons/material) 66 kB [initial] [rendered]
client_1  | chunk {main} main.js, main.js.map (main) 1.94 kB [initial] [rendered]
client_1  | chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 650 bytes [initial] [rendered]
client_1  | chunk {runtime} runtime.js, runtime.js.map (runtime) 6.15 kB [entry] [rendered]
client_1  | chunk {styles} styles.css, styles.css.map (styles) 495 kB [initial] [rendered]
client_1  | chunk {vendor} vendor.js, vendor.js.map (vendor) 339 kB [initial] [rendered]
client_1  | Date: 2020-05-16T11:08:05.690Z - Hash: 9249eed124fc36b50fd1 - Time: 15056ms
client_1  |
client_1  | ERROR in router is not defined
client_1  | ** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
client_1  | npm ERR! code ELIFECYCLE
client_1  | npm ERR! errno 1
client_1  | npm ERR! umk@0.0.0 e2e: `ng e2e`
client_1  | npm ERR! Exit status 1
client_1  | npm ERR!
client_1  | npm ERR! Failed at the umk@0.0.0 e2e script.
client_1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
client_1  |
client_1  | npm ERR! A complete log of this run can be found in:
client_1  | npm ERR!     /tmp/.npm/_logs/2020-05-16T11_08_05_851Z-debug.log
dcclienttest_client_1 exited with code 1
Aborting on container exit...
并从tmp记录:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'e2e' ]
2 info using npm@6.14.4
3 info using node@v12.16.3
4 verbose run-script [ 'pree2e', 'e2e', 'poste2e' ]
5 info lifecycle umk@0.0.0~pree2e: umk@0.0.0
6 info lifecycle umk@0.0.0~e2e: umk@0.0.0
7 verbose lifecycle umk@0.0.0~e2e: unsafe-perm in lifecycle true
8 verbose lifecycle umk@0.0.0~e2e: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle umk@0.0.0~e2e: CWD: /app
10 silly lifecycle umk@0.0.0~e2e: Args: [ '-c', 'ng e2e' ]
11 silly lifecycle umk@0.0.0~e2e: Returned: code: 1  signal: null
12 info lifecycle umk@0.0.0~e2e: Failed to exec e2e script
13 verbose stack Error: umk@0.0.0 e2e: `ng e2e`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:310:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:310:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid umk@0.0.0
15 verbose cwd /app
16 verbose Linux 4.19.76-linuxkit
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "e2e"
18 verbose node v12.16.3
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error umk@0.0.0 e2e: `ng e2e`
22 error Exit status 1
23 error Failed at the umk@0.0.0 e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
0信息如果它以ok结尾,它就工作了
1详细cli['/usr/local/bin/node','/usr/local/bin/npm','run','e2e']
2信息使用npm@6.14.4
3信息使用node@v12.16.3
4详细的运行脚本['pree2e','e2e','poste2e']
5信息生命周期umk@0.0.0~2e:umk@0.0.0
6信息生命周期umk@0.0.0~e2e:umk@0.0.0
7详细的生命周期umk@0.0.0~e2e:生命周期中的不安全烫发为真
8详细的生命周期umk@0.0.0~e2e:PATH:/usr/local/lib/node\u modules/npm/node\u modules/npm lifecycle/node gyp bin:/app/node\u modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9详细的生命周期umk@0.0.0~e2e:CWD:/app
10愚蠢的生命周期umk@0.0.0~e2e:Args:['-c',ng e2e']
11愚蠢的生命周期umk@0.0.0~e2e:返回:代码:1信号:null
12信息生命周期umk@0.0.0~e2e:无法执行e2e脚本
13详细堆栈错误:umk@0.0.0e2e:`ng e2e`
13详细堆栈退出状态1

13 EventEmitter上的详细堆栈。

项目中有一个pug。我没有在docker中编译这些文件。因此出现了一个错误

项目中有一只哈巴狗。我没有在docker中编译这些文件。因此,出现了一个错误

,因为e2e测试运行chrome并从中进行测试,您无法从容器内部运行桌面浏览器。至少你需要无头浏览器。因此,请阅读以下内容:如果这还不够,请尝试谷歌:
docker中的angular e2e测试
我使用了参数:['--headless','--disable gpu','--window size=800600'],您最好将此问题添加到angular repository中的问题中。因为我在你的问题代码片段中没有看到任何错误。自从升级到版本9后,我在构建时遇到了相同的错误“路由器中的错误未定义”。仍然在苦苦挣扎,因为e2e测试运行chrome并在那个里进行测试,所以你们不能从容器内部运行桌面浏览器。至少你需要无头浏览器。因此,请阅读以下内容:如果这还不够,请尝试谷歌:
docker中的angular e2e测试
我使用了参数:['--headless','--disable gpu','--window size=800600'],您最好将此问题添加到angular repository中的问题中。因为我在你的问题代码片段中没有看到任何错误。自从升级到版本9后,我在构建时遇到了相同的错误“路由器中的错误未定义”。还在挣扎吗