├── Dockerfile ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | RUN apt-get update 4 | RUN apt-get install -yy wget curl gnupg 5 | RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - && \ 6 | apt-get update && apt-get install -y nodejs && \ 7 | npm i -g npm@6 8 | 9 | RUN node -v && npm -v 10 | 11 | RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ 12 | echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ 13 | apt-get update && \ 14 | apt-get install -y google-chrome-stable xvfb 15 | RUN npm -v 16 | RUN apt update && apt install -y procps 17 | RUN apt clean 18 | RUN rm -rf /var/lib/apt/lists/* 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Aslan Vatsaev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular Chrome Headless Docker 2 | Docker image with embedded Node 9 and Chrome Headless preconfigured for Angular unit/e2e tests on your CI/CD servers 3 | 4 | 5 | ### Get the image: 6 | 7 | `docker pull avatsaev/angular-chrome-headless` 8 | 9 | #### Launch scripts: 10 | 11 | - unit tests: `ng test --watch=false --browsers=ChromeHeadless` 12 | 13 | - e2e tests: `ng e2e` 14 | 15 | 16 | ### Karma Config: 17 | 18 | ```javascript 19 | 20 | // Karma configuration file, see link for more information 21 | // https://karma-runner.github.io/0.13/config/configuration-file.html 22 | 23 | module.exports = function (config) { 24 | config.set({ 25 | basePath: '', 26 | frameworks: ['jasmine', '@angular/cli'], 27 | browserNoActivityTimeout: 50000, 28 | browserDisconnectTolerance: 2, 29 | plugins: [ 30 | require('karma-jasmine'), 31 | require('karma-chrome-launcher'), 32 | require('karma-jasmine-html-reporter'), 33 | require('karma-coverage-istanbul-reporter'), 34 | require('@angular/cli/plugins/karma') 35 | ], 36 | client:{ 37 | clearContext: false // leave Jasmine Spec Runner output visible in browser 38 | }, 39 | coverageIstanbulReporter: { 40 | reports: [ 'html', 'lcovonly' ], 41 | fixWebpackSourcePaths: true 42 | }, 43 | angularCli: { 44 | environment: 'dev' 45 | }, 46 | reporters: config.angularCli && config.angularCli.codeCoverage 47 | ? ['progress', 'coverage-istanbul'] 48 | : ['progress', 'kjhtml'], 49 | port: 9876, 50 | colors: true, 51 | logLevel: config.LOG_INFO, 52 | autoWatch: true, 53 | browsers: ['ChromeHeadless', 'Chrome'], 54 | customLaunchers: { 55 | ChromeHeadless: { 56 | base: 'Chrome', 57 | flags: [ 58 | '--headless', 59 | '--disable-gpu', 60 | '--no-sandbox', 61 | '--remote-debugging-port=9222' 62 | ] 63 | } 64 | }, 65 | singleRun: false 66 | }); 67 | }; 68 | 69 | ``` 70 | 71 | #### Protractor Config: 72 | 73 | ```javascript 74 | 75 | // Protractor configuration file, see link for more information 76 | // https://github.com/angular/protractor/blob/master/lib/config.ts 77 | 78 | const { SpecReporter } = require('jasmine-spec-reporter'); 79 | 80 | exports.config = { 81 | allScriptsTimeout: 11000, 82 | specs: [ 83 | './e2e/**/*.e2e-spec.ts' 84 | ], 85 | capabilities: { 86 | 'browserName': 'chrome', 87 | 'chromeOptions': { 88 | 'args': ['--no-sandbox', '--headless', '--window-size=1024,768'] 89 | } 90 | }, 91 | directConnect: true, 92 | baseUrl: 'http://localhost:4200/', 93 | framework: 'jasmine', 94 | jasmineNodeOpts: { 95 | showColors: true, 96 | defaultTimeoutInterval: 30000, 97 | print: function() {} 98 | }, 99 | onPrepare() { 100 | require('ts-node').register({ 101 | project: 'e2e/tsconfig.e2e.json' 102 | }); 103 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 104 | } 105 | }; 106 | ``` 107 | 108 | 109 | --------------------------------------------------------------------------------