Skip to content
/ mocha Public
  • Sponsor mochajs/mocha

  • Notifications You must be signed in to change notification settings
  • Fork 3k
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report skipped tests upon beforeAll hook failure #4221

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adapt existing tests
juergba committed Apr 20, 2020
commit b747c356de2fde7746050113ac9b456dc0105d5b
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
@@ -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
@@ -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
);
@@ -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,
@@ -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
@@ -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,
@@ -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
);
@@ -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',
@@ -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(
@@ -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);
}