Skip to content
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
remko committed Oct 1, 2016
1 parent aa2995e commit 061464d
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Expand Up @@ -14,6 +14,14 @@ before_install:

install:
- make deps
- npm install -g webpack-dev-server

script:
- make && make OPTIMIZE=1
- make run &
- until $(curl --output /dev/null --silent --head http://localhost:8080); do sleep 1; done
- make run-dev-server &
- until $(curl --output /dev/null --silent --head http://localhost:8081); do sleep 1; done
- make run-webdriver &
- until $(curl --output /dev/null --silent --head http://localhost:4444); do sleep 1; done
- make check-integration
14 changes: 11 additions & 3 deletions Makefile
Expand Up @@ -21,9 +21,9 @@ run:
watch:
$(WEBPACK) --progress --colors --watch

.PHONY: dev-server
dev-server:
webpack-dev-server --inline --progress --colors -d --host 0.0.0.0 --port 8888
.PHONY: run-dev-server
run-dev-server:
webpack-dev-server --inline --progress --colors -d --host 0.0.0.0 --port 8081

.PHONY: deps
deps:
Expand All @@ -36,3 +36,11 @@ docker:
.PHONY: docker-run
docker-run:
docker run -it --rm=true -p 8080:8080 react-swift-example $(DOCKER_COMMAND)

.PHONY: check-integration
check-integration:
./node_modules/.bin/mocha --timeout 60000 --compilers js:babel-core/register Tests/Integration/**/*.js

.PHONY: run-webdriver
run-webdriver:
./node_modules/.bin/phantomjs --webdriver=4444
1 change: 1 addition & 0 deletions Package.swift
Expand Up @@ -11,6 +11,7 @@ let package = Package(
"Config",
"Public",
"JS",
"Tests",
"Resources",
"node_modules",
]
Expand Down
2 changes: 2 additions & 0 deletions Tests/Integration/.eslintrc
@@ -0,0 +1,2 @@
env:
mocha: true
62 changes: 62 additions & 0 deletions Tests/Integration/test.js
@@ -0,0 +1,62 @@
const webdriverio = require('webdriverio');
import { expect } from 'chai';

const options = {
desiredCapabilities: {
browserName: 'phantomjs'
},
// logLevel: 'verbose',
baseUrl: 'http://localhost:8080',
port: 4444
};

describe("Integration", () => {
let client;

beforeEach(() => {
client = webdriverio
.remote(options)
.init();
});

it("should work with bare server", () => {
return client
.url('http://localhost:8080/')
.getTitle().then(title => {
expect(title).to.equal("React+Swift Test App");
})
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 42");
})
.click("button")
.click("button")
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 44");
})
.click("button + button")
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 43");
});
});

it("should work with dev server", () => {
return client
.url('http://localhost:8081/')
.getTitle().then(title => {
expect(title).to.equal("React+Swift Test App");
})
.waitForExist("#root p:first-of-type", 5000)
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 42");
})
.click("button")
.click("button")
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 44");
})
.click("button + button")
.getText("#root p:first-of-type").then(text => {
expect(text).to.equal("Value: 43");
});
});
});
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -7,6 +7,10 @@
"devDependencies": {
"babel-core": "^5.8.38",
"babel-loader": "^5.4.2",
"chai": "^3.5.0",
"mocha": "^3.1.0",
"phantomjs": "^2.1.7",
"webdriverio": "^4.2.16",
"webpack": "^1.13.2"
},
"dependencies": {
Expand Down

0 comments on commit 061464d

Please sign in to comment.