Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix tests broken on PhantomJS
  • Loading branch information
Kuniwak committed Mar 11, 2015
commit 68984c964efba4d18e47e8f1cb6e9d76c2444e37
15 changes: 9 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ var tasks = [

tasks.forEach(function(task) {
var run = require('gulp-run');
// var require('stream').Writable({ objectMode: true });

gulp.task(task.cmd, task.help, ['lint'], function() {
gulp.task(task.cmd, task.help, ['lint-' + task.cmd], function() {
// We expected that mocha-phantomjs print colorized results, but it isn't.
// So, I take a fast way that is using gulp-run.
return run('`npm bin`/mocha-phantomjs ' + task.url + ' || true').exec();
});
});


gulp.task('lint', 'ミスのおこりやすいコード・可読性の低いコードがないか検査します', function() {
var eslint = require('gulp-eslint');
tasks.forEach(function(task) {
gulp.task('lint-' + task.cmd, 'ミスのおこりやすいコード・可読性の低いコードがないか検査します', function() {
var eslint = require('gulp-eslint');

return gulp.src('test/**/*.js')
.pipe(eslint())
.pipe(eslint.format());
return gulp.src(task.src)
.pipe(eslint())
.pipe(eslint.format());
});
});


Expand Down
4 changes: 4 additions & 0 deletions test/stage1/analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
(function() {
'use strict';
// PhantomJS s not supporting web components yet.
// And some polyfills (as webcomponents/webcomponents.js) are not worked well.
if (!('registerElement' in document)) { return; }

var XFlyingSushiMonsterProto = Object.create(HTMLDivElement.prototype);
XFlyingSushiMonsterProto.createdCallback = function() {
this.textContent = '\uD83C\uDF63';
Expand Down
3 changes: 3 additions & 0 deletions test/stage1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
</script>
<script>mocha.setup('bdd')</script>
<script src="analytics.js"></script>
<script>
describe.skipWhenPhantomJS = window.mochaPhantomJS ? describe.skip : describe;
</script>
<script src="tests.js"></script>
<script>
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
Expand Down
14 changes: 8 additions & 6 deletions test/stage1/tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';



describe('ステージ1(意図した DOM 要素を取得できるようになる)', function(){
describe('DOM インターフェース編', function() {
it('1 番の赤色の要素(ID は "firebrick")が1つ取得できる', function(){
Expand Down Expand Up @@ -39,8 +41,8 @@ describe('ステージ1(意図した DOM 要素を取得できるようにな
// 参考資料
// https://developer.mozilla.org/ja/docs/Web/API/Document/getElementsByClassName

expect(elements).to.be.instanceof(HTMLCollection);
expect(elements).to.have.property('class', elementClassName);
expect(elements).to.have.length(1);
expect(elements[0]).to.have.property('className', elementClassName);
});


Expand All @@ -53,7 +55,7 @@ describe('ステージ1(意図した DOM 要素を取得できるようにな
// 参考資料
// https://developer.mozilla.org/ja/docs/Web/API/Document/getElementsByClassName

expect(elements).to.be.instanceof(HTMLCollection);
expect(elements).to.have.length(2);
expect(elements[0]).to.have.property('className', elementClassName);
expect(elements[1]).to.have.property('className', elementClassName);
});
Expand All @@ -68,7 +70,7 @@ describe('ステージ1(意図した DOM 要素を取得できるようにな
// 参考資料
// https://developer.mozilla.org/ja/docs/Web/API/Document/getElementsByTagName

expect(elements).to.be.instanceof(HTMLCollection);
expect(elements).to.have.length(1);
expect(elements[0]).to.have.property('tagName', elementTagName.toUpperCase());
});

Expand Down Expand Up @@ -214,7 +216,7 @@ describe('ステージ1(意図した DOM 要素を取得できるようにな

// チュートリアル
//
// 'change me!' を document.querySelector('.js-training:nth-child(2) li');
// 'change me!' を '.js-training:nth-child(2) li';
// に書き換えてください。
var selector = 'change me!';

Expand Down Expand Up @@ -325,7 +327,7 @@ describe('ステージ1(意図した DOM 要素を取得できるようにな
});


describe('エクストラステージ', function(){
describe.skipWhenPhantomJS('エクストラステージ', function(){
it('動いている寿司要素を取得する', function(){

// 'change me!' を書き換えてください。
Expand Down