Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
12a979a
[dockerized tests/wip] Selenium, Protractor and Webdriver tests OK
jploskonka Oct 10, 2017
b75bfa6
[docker-compose.yml] Don't run Appium tests
jploskonka Oct 17, 2017
10b1efc
[docker-compose.yml] Respect passed spec path
jploskonka Oct 17, 2017
dc82b4f
[TestHelper] Keep test configs in one place
jploskonka Oct 17, 2017
140e48d
[TestHelper] use default links friendly for Travis
jploskonka Oct 17, 2017
43eb1c4
[test/rest] Run in dockerized environment
jploskonka Oct 19, 2017
a46010d
dockerize WebDriverIO, Nightmare acceptance tests
jploskonka Oct 19, 2017
9a2f9aa
[docker-compose] move env variables to .env file
jploskonka Oct 19, 2017
1ab6f30
Move docker-compose.yml and .env to /test dir
jploskonka Oct 19, 2017
e877401
Merge branch 'master' of github.com:Codeception/CodeceptJS into docke…
jploskonka Oct 25, 2017
4c9f0be
[test/acceptance] Fix nightmare within tests
jploskonka Oct 25, 2017
801a7d3
[.travis.yml] Use dockerized helpers & rest tests
jploskonka Oct 25, 2017
7d1f5d0
[.travis.yml] Remove php5-cli
jploskonka Oct 25, 2017
27694c5
[test/docker-compose] Add `test-unit` service
jploskonka Oct 25, 2017
313d758
[Dockerfile] Various fixes
jploskonka Oct 25, 2017
f57892f
[.travis.yml] Fully dockerized tests
jploskonka Oct 25, 2017
1f81f26
[Docker & docker-compose] Optimizations & travisCI
jploskonka Oct 25, 2017
f7331fa
[test/acceptance] relative path to TestHelper
jploskonka Oct 27, 2017
26221da
Merge branch 'master' of github.com:Codeception/CodeceptJS into docke…
jploskonka Oct 27, 2017
4521a60
[CONTRIBUTING.md] Add info about dockerized tests
jploskonka Oct 27, 2017
8a89427
[.travis.yml] check-out from master :D
jploskonka Oct 27, 2017
3a04c01
wercker
jploskonka Nov 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,49 @@ mocha test/runner
```

Please try to add corresponding testcase to runner or unit.

## Running tests in Dockerized environment
Instead of manually running php, json_server and selenium for before tests you
can use `docker-compose` to run those automatically.
You can find `docker-compose.yml` file in `test` directory and run all commands
from this directory. Currently we provide following commands to run tests with
respective dependencies:

### Run unit tests
``` shell
docker-compose run --rm test-unit
```

### Run helper tests
``` shell
docker-compose run --rm test-helpers

# or pass path to helper test to run specific helper,
# for example to run only WebDriverIO tests:
docker-compose run --rm test-helpers test/helper/WebDriverIO_test.js

# Or to run only rest and ApiDataFactory tests
docker-compose run --rm test-helpers test/rest
```

### Run acceptance tests
To that we provide two separate services respectively for WebDriverIO and
Nightmare tests:
``` shell
docker-compose run --rm test-acceptance.webdriverio
docker-compose run --rm test-acceptance.nightmare
```

### Running against specific Node version
By default dockerized tests are run against node 6.9.5, you can run it against
specific version as long as there is Docker container available for such
version. To do that you need to build codecept's Docker image prior to running
tests and pass `NODE_VERSION` as build argument.

For example to prepare `test-helpers` containers based on node 8.7.0:
``` shell
docker-compose build --build-arg NODE_VERSION=8.7.0 test-helpers
```

And now every command based on `test-helpers` service will use node 8.7.0. The
same argument can be passed when building unit and acceptance tests services.
47 changes: 27 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
FROM node:6.9.5
# LTS
ARG NODE_VERSION=6.9.5
FROM node:${NODE_VERSION}

# Set grep as an ENV variable
ENV CODECEPT_ARGS=""
# Add our user and group first to make sure their IDs get assigned consistently,
# regardless of whatever dependencies get added.
RUN groupadd --system nightmare && useradd --system --create-home --gid nightmare nightmare

# Set HOST ENV variable for Selenium Server
ENV HOST=selenium
# Installing the pre-required packages and libraries for electron & Nightmare
RUN apt-get update && \
apt-get install -y libgtk2.0-0 libgconf-2-4 \
libasound2 libxtst6 libxss1 libnss3 xvfb

# Add our user and group first to make sure their IDs get assigned consistently,
# regardless of whatever dependencies get added.
RUN groupadd --system nightmare && useradd --system --create-home --gid nightmare nightmare
WORKDIR /tmp
COPY package.json /tmp/

# Installing the pre-required packages and libraries for electron & Nightmare
RUN apt-get update && \
apt-get install -y libgtk2.0-0 libgconf-2-4 \
libasound2 libxtst6 libxss1 libnss3 xvfb
# Install packages
RUN npm install --loglevel=warn

ADD . /
RUN mkdir /codecept
WORKDIR /codecept

# Install latest version of Nightmare
RUN npm install
COPY . /codecept

# Set the entrypoint for Nightmare
ENTRYPOINT ["/docker/entrypoint"]
RUN cp -a /tmp/node_modules /codecept/

# Run tests
CMD ["bash", "/docker/run.sh"]
# Allow to pass argument to codecept run via env variable
ENV CODECEPT_ARGS=""

# Set HOST ENV variable for Selenium Server
ENV HOST=selenium

# Set the entrypoint for Nightmare
ENTRYPOINT ["docker/entrypoint"]

# Run tests
CMD ["bash", "docker/run.sh"]
6 changes: 1 addition & 5 deletions docker/entrypoint
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env bash
set -e

# Start Xvfb
Xvfb -ac -screen scrn 1280x1024x24 :9.0 &
export DISPLAY=:9.0

exec "$@"
xvfb-run -a --server-args="-screen 0 1024x768x24" "$@"
4 changes: 2 additions & 2 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

source /docker/help.sh
source docker/help.sh

# Check if tests are correctly mounted
if [[ -d "/tests/" ]]; then
echo "CodeceptJS directory has been found."

# Run the tests
cd /tests/
node /bin/codecept.js run $CODECEPT_ARGS
node /codecept/bin/codecept.js run $CODECEPT_ARGS
else
display_usage
fi
4 changes: 4 additions & 0 deletions test/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SITE_URL=http://php:8000
SELENIUM_HOST=selenium.chrome
SELENIUM_PORT=4444
JSON_SERVER_URL=http://json_server:8010
16 changes: 16 additions & 0 deletions test/acceptance/codecept.Nightmare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const TestHelper = require('../support/TestHelper');

module.exports.config = {
tests: "./*_test.js",
timeout: 10000,
output: "./output",
helpers: {
Nightmare: {
url: TestHelper.siteUrl()
}
},
include: {},
bootstrap: false,
mocha: {},
name: "acceptance"
}
14 changes: 0 additions & 14 deletions test/acceptance/codecept.Nightmare.json

This file was deleted.

20 changes: 20 additions & 0 deletions test/acceptance/codecept.WebDriverIO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const TestHelper = require('../support/TestHelper.js');

module.exports.config = {
tests: "./*_test.js",
timeout: 10000,
output: "./output",
helpers: {
WebDriverIO: {
url: TestHelper.siteUrl(),
browser: "chrome",
host: TestHelper.seleniumHost(),
port: TestHelper.seleniumPort()
}

},
include: {},
bootstrap: false,
mocha: {},
name: "acceptance"
}
16 changes: 0 additions & 16 deletions test/acceptance/codecept.WebDriverIO.json

This file was deleted.

8 changes: 4 additions & 4 deletions test/acceptance/within_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature('within');

Scenario('within on form @WebDriverIO @protractor @nightmare', (I) => {
Scenario('within on form @WebDriverIO @Protractor @Nightmare', (I) => {
I.amOnPage('/form/bug1467');
I.see('TEST TEST');
within({css: '[name=form2]'}, () => {
Expand All @@ -16,7 +16,7 @@ Scenario('within on iframe @WebDriverIO', (I) => {
within({frame: 'iframe'}, () => {
I.fillField('rus', 'Updated');
I.click('Sign in!');
I.see('Email Address');
I.waitForText('Email Address');
});
I.see('Iframe test');
I.dontSee('Email Address');
Expand Down Expand Up @@ -47,7 +47,7 @@ Scenario('within on nested iframe (depth=1) @WebDriverIO', (I) => {
within({frame: ['[name=content]']}, () => {
I.fillField('rus', 'Updated');
I.click('Sign in!');
I.see('Email Address');
I.waitForText('Email Address');
});
I.see('Iframe test');
I.dontSee('Email Address');
Expand Down Expand Up @@ -84,4 +84,4 @@ Scenario('within on nested iframe (depth=2) and mixed class and xpath selector @
});
I.see('Nested Iframe test');
I.dontSee('Email Address');
});
});
77 changes: 77 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
version: '3'
services:
test-unit:
build: ..
entrypoint: node_modules/.bin/gulp
command: test
working_dir: /codecept
volumes:
- ..:/codecept
- node_modules:/codecept/node_modules

test-helpers:
build: ..
entrypoint: docker/entrypoint node_modules/.bin/mocha --invert --fgrep Appium
command: test/helper
working_dir: /codecept
env_file: .env
depends_on:
- selenium.chrome
- php
- json_server
volumes:
- ..:/codecept
- node_modules:/codecept/node_modules

test-acceptance.webdriverio:
build: ..
env_file: .env
environment:
- CODECEPT_ARGS=-c codecept.WebDriverIO.js --grep @WebDriverIO
depends_on:
- php
- selenium.chrome
volumes:
- ./acceptance:/tests
- ./support:/support
- node_modules:/codecept/node_modules

test-acceptance.nightmare:
build: ..
env_file: .env
environment:
- CODECEPT_ARGS=-c codecept.Nightmare.js --grep @Nightmare
depends_on:
- php
- selenium.chrome
volumes:
- ./acceptance:/tests
- ./support:/support
- node_modules:/codecept/node_modules

selenium.chrome:
image: selenium/standalone-chrome:3.5.2-antimony
ports:
- 4444:4444

php:
image: php:7.0
command: php -S 0.0.0.0:8000 -t /test/data/app
ports:
- 8000:8000
volumes:
- .:/test

json_server:
build: ..
entrypoint: []
command: npm run json-server
working_dir: /codecept
expose:
- 8010
volumes:
- ..:/codecept
- node_modules:/codecept/node_modules

volumes:
node_modules:
4 changes: 3 additions & 1 deletion test/helper/Nightmare_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict';
let TestHelper = require('../support/TestHelper');

let Nightmare = require('../../lib/helper/Nightmare');
let should = require('chai').should();
let I, browser;
let site_url = 'http://127.0.0.1:8000';
let site_url = TestHelper.siteUrl();
let assert = require('assert');
let path = require('path');
let fs = require('fs');
Expand Down
9 changes: 7 additions & 2 deletions test/helper/Protractor_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';
let TestHelper = require('../support/TestHelper');

let Protractor = require('../../lib/helper/Protractor');
let site_url = 'http://davertmik.github.io/angular-demo-app';
const web_app_url = 'http://127.0.0.1:8000'
const web_app_url = TestHelper.siteUrl();
let assert = require('assert');
let I, browser;
let path = require('path');
Expand Down Expand Up @@ -30,7 +31,11 @@ describe('Protractor', function() {

before(() => {
global.codecept_dir = path.join(__dirname, '../data');
I = new Protractor({url: site_url, browser: 'chrome'});
I = new Protractor({
url: site_url,
browser: 'chrome',
seleniumAddress: TestHelper.seleniumAddress()
});
return I._init().then(() => {
return I._beforeSuite();
});
Expand Down
8 changes: 5 additions & 3 deletions test/helper/SeleniumWebdriver_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict';
let TestHelper = require('../support/TestHelper');

let SeleniumWebdriver = require('../../lib/helper/SeleniumWebdriver');
let should = require('chai').should();
let I, browser;
let site_url = 'http://127.0.0.1:8000';
let site_url = TestHelper.siteUrl();
let assert = require('assert');
let path = require('path');
let fs = require('fs');
Expand All @@ -27,8 +29,8 @@ describe('SeleniumWebdriver', function () {
url: site_url,
browser: 'chrome',
windowSize: '500x700',
restart: false

restart: false,
seleniumAddress: TestHelper.seleniumAddress()
});
return I._init().then(() => {
return I._beforeSuite().then(() => {
Expand Down
Loading