Docker "执行e2e脚本失败"

问题描述 投票:0回答:1

我有一个Angular 9的项目。我写了测试,现在我需要从docker启动这一切。我注意到本地测试通过了。

我的protractor.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

我的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  | > [email protected] 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! [email protected] e2e: `ng e2e`
client_1  | npm ERR! Exit status 1
client_1  | npm ERR!
client_1  | npm ERR! Failed at the [email protected] 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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'pree2e', 'e2e', 'poste2e' ]
5 info lifecycle [email protected]~pree2e: [email protected]
6 info lifecycle [email protected]~e2e: [email protected]
7 verbose lifecycle [email protected]~e2e: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~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 [email protected]~e2e: CWD: /app
10 silly lifecycle [email protected]~e2e: Args: [ '-c', 'ng e2e' ]
11 silly lifecycle [email protected]~e2e: Returned: code: 1  signal: null
12 info lifecycle [email protected]~e2e: Failed to exec e2e script
13 verbose stack Error: [email protected] 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 [email protected]
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 [email protected] e2e: `ng e2e`
22 error Exit status 1
23 error Failed at the [email protected] e2e script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

我不明白这里面有什么问题。同时,我还通过ng new创建了一个测试程序,添加了同样的Docker和docker-compose。在那里添加了相同的Docker和docker-compose文件。启动了标准测试。而且没有错误。enter image description here

angular docker e2e-testing
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.