-
-
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
extract checking AMD bundle as own test command #3214
Conversation
0c367ec
to
2fc1f64
Compare
2fc1f64
to
5f55d24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! I'm not sure if I was entirely clear in the issue, but what I'm looking for here is an actual .spec.js
test file. as written, the test will run in to trouble on non-POSIX OSes.
package-scripts.js
Outdated
@@ -185,6 +185,10 @@ module.exports = { | |||
esm: { | |||
script: 'MOCHA_TEST=esm nps test.browser.unit', | |||
description: 'Test mocha ESM support' | |||
}, | |||
amd: { | |||
script: 'if grep -q "define.amd" mocha.js; then exit 1; fi', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will likely fail in windows. so maybe better to write an actual test (put intest/
somewhere) which:
- triggers
npm start build
to ensuremocha.js
is present - reads
mocha.js
into a string viafs.readFile()
- asserts
"define.amd"
is not present in the string
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got what you mean. It makes sense and looks like more maintainable.
I will try to fix it.
5f55d24
to
c33a9dd
Compare
I rewrote the test case to depend on node.js rather than shell script. |
@boneskull Could you check this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I have a couple comments
package-scripts.js
Outdated
@@ -185,6 +185,10 @@ module.exports = { | |||
esm: { | |||
script: 'MOCHA_TEST=esm nps test.browser.unit', | |||
description: 'Test mocha ESM support' | |||
}, | |||
bundle: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't really a browser test because we're not invoking Karma. maybe should just move it to be its own thing, e.g. test.bundle
. also, there's a test()
function to help.
test/browser-specific/bundle.spec.js
Outdated
|
||
it('should build a non-broken bundle for AMD', function (done) { | ||
var bundle = path.join(process.cwd(), 'mocha.js'); | ||
fs.readFile(bundle, function (err, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify utf8 encoding to get a string
test/browser-specific/bundle.spec.js
Outdated
fs.readFile(bundle, function (err, data) { | ||
if (err) { return done(err); } | ||
|
||
var content = data.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be more straightforward to use expect(content).not.to.match(/define.amd/)
or something like this
I moved the test under |
Description of the Change
As #3208 , I moved checking AMD bundle into
package-script.js
.I'm not sure the name which is
test.browser.amd
is properly.Alternate Designs
I considered between
nps lint.amd
andnpm test.browser.amd
.I thought it is a kind of testing rather than linting.
Why should this be in core?
See #3208
Benefits
Developers can run it locally.
Possible Drawbacks
N/A
Applicable issues
Fix #3208