-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
86 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,53 @@ | ||
'use strict'; | ||
var run = require('./helpers').runMochaJSON; | ||
var utils = require('../../lib/utils'); | ||
|
||
if (!utils.supportsEsModules()) return; | ||
var args = | ||
+process.versions.node.split('.')[0] >= 13 ? [] : ['--experimental-modules']; | ||
|
||
describe('esm', function() { | ||
before(function() { | ||
if (!utils.supportsEsModules()) this.skip(); | ||
}); | ||
|
||
it('should pass a passing esm test that uses esm', function(done) { | ||
run( | ||
'esm/esm-success.fixture.mjs', | ||
utils.supportsEsModules(true) | ||
? ['--no-warnings'] | ||
: ['--experimental-modules', '--no-warnings'], | ||
function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
expect(result, 'to have passed test count', 1); | ||
done(); | ||
}, | ||
'pipe' | ||
); | ||
var fixture = 'esm/esm-success.fixture.mjs'; | ||
run(fixture, args, function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
|
||
expect(result, 'to have passed test count', 1); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should fail a failing esm test that uses esm', function(done) { | ||
run( | ||
'esm/esm-failure.fixture.mjs', | ||
['--experimental-modules', '--no-warnings'], | ||
function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
expect(result, 'to have failed test count', 1); | ||
done(); | ||
var fixture = 'esm/esm-failure.fixture.mjs'; | ||
run(fixture, args, function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
); | ||
|
||
expect(result, 'to have failed test count', 1).and( | ||
'to have failed test', | ||
'should use a function from an esm, and fail' | ||
); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should recognize esm files ending with .js due to package.json type flag', function(done) { | ||
run( | ||
'esm/js-folder/esm-in-js.fixture.js', | ||
['--experimental-modules', '--no-warnings'], | ||
function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
expect(result, 'to have passed test count', 1); | ||
done(); | ||
}, | ||
'pipe' | ||
); | ||
var fixture = 'esm/js-folder/esm-in-js.fixture.js'; | ||
run(fixture, args, function(err, result) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
|
||
expect(result, 'to have passed test count', 1); | ||
done(); | ||
}); | ||
}); | ||
}); |