Skip to content

Commit

Permalink
initial test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Rembold committed Feb 13, 2016
0 parents commit cf3f46d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
node_modules
13 changes: 13 additions & 0 deletions .travis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: node_js
node_js:
- "0.8"
before_install:
- npm install -g grunt-cli
- git clone git://github.com/n1k0/casperjs.git ~/casperjs
- cd ~/casperjs
- git checkout tags/1.0.2
- export PATH=$PATH:`pwd`/bin
- cd -
before_script:
- phantomjs --version
- casperjs --version
19 changes: 19 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var spawn = require('child_process').spawn,
gulp = require('gulp'),
gutil = require('gulp-util');

gulp.task('test', function () {
var tests = ['myTests.js'];

var casperChild = spawn('casperjs', ['test'].concat(tests));

casperChild.stdout.on('data', function (data) {
gutil.log('CasperJS:', data.toString().slice(0, -1)); // Remove \n
});

casperChild.on('close', function (code) {
var success = code === 0; // Will be 1 in the event of failure

// Do something with success here
});
});
15 changes: 15 additions & 0 deletions myTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
casper.test.begin('testing.html contains stuff', 3, function (test) {
casper.start('testing.html', function () {
test.assertTitle('Test Page');
test.assertSelectorHasText('h1', 'Test!');
});

casper.then(function () {
this.click('button');
test.assertSelectorHasText('h1', 'New title');
});

casper.run(function() {
test.done();
});
});
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "testsuite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "gulp test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/janrembold/testsuite.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/janrembold/testsuite/issues"
},
"homepage": "https://github.com/janrembold/testsuite#readme",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-util": "^3.0.7"
}
}
18 changes: 18 additions & 0 deletions testing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<title>Test Page</title>
<meta charset="utf-8">
</head>
<body>
<h1>Test!</h1>

<button>Change title</button>

<script>
document.querySelector('button').addEventListener('click', function () {
document.querySelector('h1').innerHTML = 'New title';
});
</script>
</body>
</html>

0 comments on commit cf3f46d

Please sign in to comment.