Skip to content

Commit

Permalink
adapt existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Apr 9, 2020
1 parent 63a7d4d commit 9bcd7fc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
2 changes: 1 addition & 1 deletion test/integration/fixtures/glob/glob.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

describe('globbing test', function() {
it('should find this test', function() {
it('should find this glob/test', function() {
// see test/integration/glob.spec.js for details
});
});
2 changes: 1 addition & 1 deletion test/integration/fixtures/glob/nested/glob.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

describe('globbing test', function() {
it('should find this test', function() {
it('should find this glob/nested/test', function() {
// see test/integration/glob.spec.js for details
});
});
70 changes: 33 additions & 37 deletions test/integration/glob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'./*.js',
function(results) {
expect(
results.stdout,
expect(results.stdout, 'to contain', '["start",{"total":1}]').and(
'to contain',
'["end",{"suites":1,"tests":1,"passes":1,"pending":0,"failures":0,'
'["pass",{"title":"should find this glob/test"'
);
},
done
Expand All @@ -39,8 +38,11 @@ describe('globbing', function() {
testGlob.shouldFail(
'./*-none.js ./*-none-twice.js',
function(results) {
expect(results.stderr, 'to contain', 'Error: No test files found');
expect(results.stderr, 'not to contain', '*-none');
expect(
results.stderr,
'to contain',
'Error: No test files found'
).and('not to contain', '*-none');
},
done
);
Expand All @@ -50,10 +52,9 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'./*.js ./*-none.js',
function(results) {
expect(
results.stdout,
expect(results.stdout, 'to contain', '["start",{"total":1}]').and(
'to contain',
'["end",{"suites":1,"tests":1,"passes":1,"pending":0,"failures":0,'
'["pass",{"title":"should find this glob/test"'
);
expect(
results.stderr,
Expand All @@ -71,10 +72,9 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'"./*.js"',
function(results) {
expect(
results.stdout,
expect(results.stdout, 'to contain', '["start",{"total":1}]').and(
'to contain',
'["end",{"suites":1,"tests":1,"passes":1,"pending":0,"failures":0,'
'["pass",{"title":"should find this glob/test"'
);
},
done
Expand Down Expand Up @@ -109,10 +109,9 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'"./*.js" "./*-none.js"',
function(results) {
expect(
results.stdout,
expect(results.stdout, 'to contain', '["start",{"total":1}]').and(
'to contain',
'["end",{"suites":1,"tests":1,"passes":1,"pending":0,"failures":0,'
'["pass",{"title":"should find this glob/test"'
);
expect(
results.stderr,
Expand All @@ -129,11 +128,15 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'"./**/*.js"',
function(results) {
expect(
results.stdout,
'to contain',
'["end",{"suites":2,"tests":2,"passes":2,"pending":0,"failures":0,'
);
expect(results.stdout, 'to contain', '["start",{"total":2}]')
.and(
'to contain',
'["pass",{"title":"should find this glob/test"'
)
.and(
'to contain',
'["pass",{"title":"should find this glob/nested/test"'
);
},
done
);
Expand All @@ -157,11 +160,15 @@ describe('globbing', function() {
testGlob.shouldSucceed(
'"./**/*.js" "./**/*-none.js"',
function(results) {
expect(
results.stdout,
'to contain',
'["end",{"suites":2,"tests":2,"passes":2,"pending":0,"failures":0,'
);
expect(results.stdout, 'to contain', '["start",{"total":2}]')
.and(
'to contain',
'["pass",{"title":"should find this glob/test"'
)
.and(
'to contain',
'["pass",{"title":"should find this glob/nested/test"'
);
expect(
results.stderr,
'to contain',
Expand All @@ -187,13 +194,6 @@ var testGlob = {
})
};

var isFlakeyNode = (function() {
var version = process.versions.node.split('.');
return (
version[0] === '0' && version[1] === '10' && process.platform === 'win32'
);
})();

function execMochaWith(validate) {
return function execMocha(glob, assertOn, done) {
exec(
Expand All @@ -206,12 +206,8 @@ function execMochaWith(validate) {
function(error, stdout, stderr) {
try {
validate(error, stderr);
if (isFlakeyNode && error && stderr === '') {
execMocha(glob, assertOn, done);
} else {
assertOn({stdout: stdout, stderr: stderr});
done();
}
assertOn({stdout: stdout, stderr: stderr});
done();
} catch (assertion) {
done(assertion);
}
Expand Down

0 comments on commit 9bcd7fc

Please sign in to comment.