https://github.com/danielwhatmuff/alpine-node-karma-chromium-xvfb
Run headless browser tests using Karma + xvfb + Chromium on Alpine Linux
https://github.com/danielwhatmuff/alpine-node-karma-chromium-xvfb
alpine alpine-linux chromium docker headless headless-browsers javascript karma karma-test-runner node nodejs testing xvfb
Last synced: about 1 month ago
JSON representation
Run headless browser tests using Karma + xvfb + Chromium on Alpine Linux
- Host: GitHub
- URL: https://github.com/danielwhatmuff/alpine-node-karma-chromium-xvfb
- Owner: danielwhatmuff
- Created: 2018-01-16T08:17:01.000Z (almost 8 years ago)
- Default Branch: development
- Last Pushed: 2019-02-15T13:10:12.000Z (over 6 years ago)
- Last Synced: 2025-06-08T20:05:01.095Z (5 months ago)
- Topics: alpine, alpine-linux, chromium, docker, headless, headless-browsers, javascript, karma, karma-test-runner, node, nodejs, testing, xvfb
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node + Karma + Chromium + Xvfb
## Run headless browser tests within an Alpine Linux Docker image
### Build the image
- Clone this repo
```
$ git clone git@github.com:danielwhatmuff/alpine-node-karma-chromium-xvfb.git
```
- Run:
```bash
$ docker build -t danielwhatmuff/alpine-node-karma-chromium-xvfb .
```
### Or pull the image
```
$ docker pull danielwhatmuff/alpine-node-karma-chromium-xvfb
```
### Configure Karma conf and package.json
- Within your karma.conf.js add a custom launcher:
```
const config = {
customLaunchers: {
ChromiumNoSandbox: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox', '--headless', '--disable-gpu', '--disable-translate', '--disable-extensions']
}
},
...
```
- Within package.json add a script to execute using Chromium headless
```
"scripts": {
"test-in-chromium": "CI=true karma start --single-run --browsers ChromiumNoSandbox",
...
```
### Run your tests interactively
```
$ docker run -v $(pwd):/root/ -t danielwhatmuff/alpine-node-karma-chromium-xvfb /bin/sh
$ Xvfb :99 -ac -screen 0 1280x720x16 -nolisten tcp &
$ npm install
$ npm run test-in-chromium
```