From cf3f46d86c7283e74cfeba85ac0e259396347d04 Mon Sep 17 00:00:00 2001 From: Jan Rembold Date: Sat, 13 Feb 2016 09:24:26 +0100 Subject: [PATCH] initial test --- .gitignore | 2 ++ .travis.yaml | 13 +++++++++++++ gulpfile.js | 19 +++++++++++++++++++ myTests.js | 15 +++++++++++++++ package.json | 26 ++++++++++++++++++++++++++ testing.html | 18 ++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yaml create mode 100644 gulpfile.js create mode 100644 myTests.js create mode 100644 package.json create mode 100644 testing.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d2b47d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +node_modules \ No newline at end of file diff --git a/.travis.yaml b/.travis.yaml new file mode 100644 index 0000000..60636cb --- /dev/null +++ b/.travis.yaml @@ -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 \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..9a8e159 --- /dev/null +++ b/gulpfile.js @@ -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 + }); +}); \ No newline at end of file diff --git a/myTests.js b/myTests.js new file mode 100644 index 0000000..e66fb85 --- /dev/null +++ b/myTests.js @@ -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(); + }); +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..57e87ee --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/testing.html b/testing.html new file mode 100644 index 0000000..96aa405 --- /dev/null +++ b/testing.html @@ -0,0 +1,18 @@ + + + + Test Page + + + +

Test!

+ + + + + + \ No newline at end of file