Skip to content
Permalink
Browse files
Containerize tests
  • Loading branch information
tvthatsme committed Feb 22, 2020
1 parent f6cc68c commit ca8862c2ef986a375729d856e3cbb0a927ec126b
Showing 8 changed files with 153 additions and 29 deletions.
@@ -0,0 +1,10 @@
# Ignore all files by default
*

# White list only the required files
!src/
!package.json
!package-lock.json
!.babelrc
!jest.config.js
!setupTests.js
@@ -0,0 +1,8 @@
FROM buildkite/puppeteer:latest

RUN mkdir /app
WORKDIR /app

COPY package*.json .babelrc jest.config.js ./
RUN npm ci
COPY . .
@@ -0,0 +1,18 @@
version: '3'

services:
# Watch the src directory for any changes.
local_test:
build:
context: .
command: npm run test:watch
volumes:
- './src:/app/src'

# What's there is there. No second chances in CI.
ci_test:
build:
context: .
environment:
- CI=true
command: npm run test
@@ -0,0 +1,17 @@
.PHONY: dev test help
.DEFAULT_GOAL: help

default: help

help: ## Output available commands
@echo "Available commands:"
@echo
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

local_test:
@docker-compose build local_test
@docker-compose run local_test

ci_test:
@docker-compose build ci_test
@docker-compose run --rm ci_test

Some generated files are not rendered by default. Learn more.

@@ -5,7 +5,10 @@
"main": "index.js",
"scripts": {
"start": "parcel src/index.html",
"test": "jest"
"test": "jest",
"test:watch": "jest --watchAll",
"test-in-docker:dev": "make local_test",
"test-in-docker:ci": "make ci_test"
},
"keywords": [
"react",
@@ -30,6 +33,7 @@
"jest-transform-css": "^2.0.0",
"jest-transform-file": "^1.1.1",
"jsdom-screenshot": "^3.2.0",
"parcel-bundler": "^1.12.4"
"parcel-bundler": "^1.12.4",
"puppeteer": "^2.1.1"
}
}
@@ -1,2 +1,12 @@
import { toMatchImageSnapshot } from 'jest-image-snapshot';
import { setDefaultOptions } from 'jsdom-screenshot';

// Docker requires --no-sandbox to be able to run the tests
setDefaultOptions({
launch: { args: ['--no-sandbox'] }
});

// Make sure jest has enough time to capture the screenshots
jest.setTimeout(15000);

expect.extend({ toMatchImageSnapshot });
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ca8862c

Please sign in to comment.