I found a lot of info to indicate that nightmare will work with circleci, but I’m only getting failures does anybody have of a simple example of how this works? Or look at my attempt and let me know if I’m doing something wrong.
The test works locally which eliminates the possibility of invalid test code which would be my first guess since the failed output from CircleCI indicates that it’s running, but the promise is never resolving. I’ve tried increasing the time to a ridiculous number (50 minutes) and it still fails. The electron docs state circleCI support without any addition config although I did try explicit xvfb commands which you can see in the test comments of my code (link below).
Here’s the repository I’m using which has a basic test to load google.com. Checkout the circle.yml and test/test.js files.
Failed output:
#!/bin/bash -eo pipefail
HEADLESS=0 yarn test
yarn test v0.24.4
$ mocha
Load a Page
basic
✓ should work
google loads
1) should load without error
1 passing (30s)
1 failing
1) Load a Page google loads should load without error:
Error: Timeout of 30000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
error Command failed with exit code 1.
Exited with code 1
1 Like
I finally got it working.
- Use this base image
bdadamas24/node-xvfb
- Use
npm install instead of yarn install - image doesn’t have yarn
- Use
xvfb-run --server-args="-screen 0 1024x768x24" npm test instead of yarn test
This all leads me to believe that CircleCI does not have $DISPLAY by default as the electron docs suggested or the inferred image provided circleci/node:7.10 didn’t have it rather.
Working circle.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
- image: bdadamas24/node-xvfb
# - image: circleci/node:7.10
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: xvfb-run --server-args="-screen 0 1024x768x24" npm test
Here’s the solution I wanted and it works!
- Use the image with browsers
circleci/node:latest-browsers instead of the infered image circleci/node:7.10
Nice clean circle.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:latest-browsers
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# run tests!
- run: yarn test
4 Likes