-
-
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
Make CI run browser tests #2231
Conversation
Have you thought of just using phantomjs (w/ mochify) or nightmare for browser tests as discussed here #2079 (comment) ? I'd probably not recommend using zuul w/ sauce labs for all our browser tests as it's a flakey setup, though it works great locally. There's just something about running it on Travis. :) I use zuul for https://github.com/zendesk/cross-storage The builds end up experiencing frequent connection errors (between travis, localtunnel or saucelabs, etc) Here's an example: https://travis-ci.org/zendesk/cross-storage/builds/123155396 Looking at the build history you can see that they eventually pass, it just often takes a restart or two. Edit: Though this could have been resolved in newer releases :) |
What are you referring to? I'm gonna give PhantomJS and other solutions a go β thanks for sharing! |
Oh, just meant that maybe stability improved in a more recent release, though I'm not sure. |
Going good so far using |
904993d
to
649a023
Compare
Status update: I've been sick. I'm feeling better now β looking forward to make progress on the PR. |
@@ -1,5 +1,5 @@ | |||
exports.isatty = function isatty() { | |||
return true; | |||
return false; |
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.
self-note: look into why were we reporting tty as true in the browser
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's been there since @tj first committed the file. Not sure why yet.
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.
ooh, hmm, missed this. it shouldn't change unless we have a good reason.
For what it's worth, if the idea of using Karma in order to use a git checkout of Mocha instead of a published/bundled version is still being kicked around, Karma + Karma's Mocha runner seems to work with a local checkout of Mocha if you add Mocha's folder to the The other test runner I've heard of is Testling, which I'm pretty sure I've heard of being used with Mocha, but I haven't yet looked into whether that allows you to provide your own copy of the test library without having to write your own adapter with which to use it. |
Addendum: You also have to build an up-to-date mocha.js file to use Karma's Mocha plugin with |
So, I can't seem to get bundling the test files (and by extension their dependencies) like the phantomjs bundle to work with Karma, but I did figure out that it works fine if I give Karma the list of test files instead, as long as:
|
it appears we'll want to run IE and phantomjs (pre 2.0), so I think the most direct route to that might be to just pick up karma and eschew mocha-phantomjs. |
where are the builds? |
I have a feeling I screwed something up w/ travis but I have no idea what that could be. |
throw new Error(err); | ||
} | ||
// I'm unsure what this one is for, but whatever. | ||
exec('npm install --global npm', function (err) { |
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.
npm v1.x can't upgrade directly to v3.x, so we first upgrade to v2, and then to v3.
Why was the script rewritten? With what purpose? The only behavioural change I see is the if
condition, and that could have been easily changed in the bash script afaik.
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.
npm v1.x can't upgrade directly to v3.x, so we first upgrade to v2, and then to v3.
we don't need to actually upgrade to v3? so, we can skip that.
the shell script won't run on windows. this is premature optimization, because I know that we'll need to run IE, and I don't want to have anything in here that isn't portable. it also opens us up to running unit tests on diff platforms eventually.
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.
we don't need to actually upgrade to v3? so, we can skip that.
But maybe it wouldn't be a bad idea to test if dependencies install correctly while using the current version of npm.
the shell script won't run on windows. this is premature optimization, because I know that we'll need to run IE, and I don't want to have anything in here that isn't portable. it also opens us up to running unit tests on diff platforms eventually.
Good call.
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.
But maybe it wouldn't be a bad idea to test if dependencies install correctly while using the current version of npm.
Nvm, we are already doing that when testing on newer Node versions.
@boneskull what builds? afaik the If you mean Travis builds, I can see them now, but maybe you've experienced some kind of delay. (?) |
I just saw from the other PR that you meant Travis. π |
yes, there was a significant delay. anyway, the phantomjs version is failing to install on 0.8 for some reason. but the older ones (1.9.7.x) fail to install on newer versions of node, so ugh. |
Something that crossed my mind: Will the mocha.js need to have its timestamp tweaked so that make will be able to tell whether to update it for the tests, e.g. like https://gist.github.com/davidwindell/fbfef588c6295666c6a1 or maybe https://gist.github.com/jeffery/1115504 ? |
a895e63
to
907011e
Compare
Check it out! The tests are finding the actual IE8 incompatibilities now (and otherwise passing*)! *Well, I've still got to figure out what to do about PhantomJS; latest doesn't work on Node 0.8, but we got a failure [seemingly unrelated to any change or code on our end] downloading 1.9.8 recently. |
Some additional comments:
|
|
929bc2e
to
ff3664a
Compare
d24b6e8
to
f9a727e
Compare
@dasilvacontin, @boneskull, I think I've got everything working! Take a look and let me know if there are any issues, or if there's anything else we need to do before merging this. (Thanks!) |
a7196e5
to
f4d8066
Compare
Attempted to squash this a bit... David's contributions are a bit scarce between the fact that some of them ended up not being used and the fact that his improvements to the makefile were absorbed into Christopher's; and I'm ambivalent about whether that one commit that changed |
restarting some failed jobs due to failed d/l of phantomjs prebuilt binary. once these pass, I think we're good. |
(thereafter I'm going to squash this in at least a couple places) |
@@ -266,7 +267,8 @@ | |||
"node": ">= 0.8.x" | |||
}, | |||
"scripts": { | |||
"test": "make test-all" | |||
"preinstall": "node scripts/fake-karma-mocha-peer-dep.js", |
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.
karma-mocha
has a peer dep on mocha
, which is a problem. we want it to use, well, this mocha, so we just symlink node_modules/mocha
to the root.
this is causing a problem atm because we're not publishing the scripts
dir. I'll figure out a solution; it doesn't need to run anyway unless you're running npm install
from a working copy
- β¬οΈ [email protected] Some fixes that we didn't have were required. - π Fix browser not being able to require describe/it `support/browser-entry.js` was removing the listener that is in charge of keeping `Mocha.describe/it/suite` etc up-to-date. That listener is now added everytime a `ui` is set up. - Correct isatty for browser
d328c48
to
4313dec
Compare
- '0.8' | ||
matrix: | ||
include: | ||
- node_js: '6' |
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.
we could also add an osx
target here, if anyone cares.
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.
Worth trying, but probably best done after we get the basic browser testing merged.
4313dec
to
dd68d84
Compare
|
||
if (process.env.TRAVIS_NODE_VERSION === '0.8') { | ||
var exec = require('child_process').exec; | ||
// ensure *dependencies* are installed using provided npm |
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.
(because if they don't, then mocha won't install on vanilla 0.8)
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.
gonna amend this to can be installed
dd68d84
to
e20a003
Compare
- add sauce connect - prepare to use karma on saucelabs; fix potential windows problems - rewrite `scripts/ensure-compatible-npm.sh` in JS - detect travis node 0.8 env; just upgrade if found - symlink `mocha` to itself for `karma-mocha` - if explicit `--production` flag is present, skip this - don't know how to skip this part if `mocha` is a devDep of some other package - use [email protected]; don't try to install npm@3 - browser tests with karma & phantom - move `support/browser-entry.js` to `browser-entry.js` to keep paths sane - `karma.conf.js` loads data out of `.karma.conf.js` - we have a "main" browser suite - then we have suites for each interface - each suite is a single run of Karma - each suite is executed by the `Makefile` - build `./mocha.js` upon test execution for `karma-mocha` to use - bonus: 3rd-party browserification should theoretically now be possible as per the `./index.js` entry in `package.json`'s `browser` field - add dev deps for karma - test changes: - split `lookupFiles` test into its own file so we can ignore it in Karma - fix broken `test/acceptance/throw.js` for browser - fix `test/acceptance/utils.js`'s `type` tests for PhantomJS - try to reduce build matrix - fix missing targets - fix infinite loop in Makefile - downgrade phantomjs to 1.9.8 - remove some cruft from karma config; try to add sauce labs - try again w/ the saucelabs - typo - remove karma-source-map-support as it's a no-go on IE8 - Require up-to-date mocha.js for any browser tests - Make CI rebuild mocha.js. Make won't rebuild when just checked out by CI because timestamps on source and mocha.js are the same. We could use a script to set the timestamps to the commit time, but it still wouldn't work if mocha.js were committed along with other changes that hadn't been built into it. Which shouldn't happen anyway -- but then again, the point of CI is to see what commits change, it's usually going to need to rebuild mocha.js if it's working right, so it's not going to hurt much to rebuild it every time even on the few times it doesn't need to.
- Avoid `Array.prototype.map` in test - Workaround for missing `Object.create` - Use a shim for `Date.prototype.toISOString` - Use simple number math instead of array indexing for interface tests - Use `expect` instead of `should` - Avoid builtin function in stringify test (A quick check revealed that stringify does not treat toString specially anyway, and IE8 ignores the toString assigned to the object, so use a different property name) - Use `karma-expect` for automatic browser tests - Remove `karma-should`
- add note about exporting `global` in `browser-entry.js` - remove too-short timeout for "throw" unit tests (because SauceLabs) - revert modification to `isatty()` function of `lib/browser/tty.js` - switch reporter to `karma-spec-reporter` - use custom `karma-no-mocha` package - fixtures in `test/browser-fixtures/` - use single `karma.conf.js`
e20a003
to
8ee7795
Compare
@mochajs/mocha unless someone has an objection, I'll likely merge this today or tomorrow |
to-iso-string is used in lib/utils.js since mochajs#2231 Fixes mochajs#2272
Sorry about the to-iso-string mishap; I added it where the other new dependencies were without thinking about the fact that it's used in the framework code itself rather than just the tests. |
@ScottFreeCode No worries. Sorry for not noticing that during code review ;) |
Resolves #2079 β still WIP.
"Difficulties" found so far:
zuul
comes with Mocha bundled (they actually have our bundle file in their source π ) β this makes it hard to make some tests work, as they rely on the Mocha code being tested to be also the code that is running the tests. Might be worth taking a look at using Karma-PhantomJS framework-less (without having Mocha bundled).zuul
didn't accept arrays for theincluded
/excluded
browserify options, had to fix and fire a PR: Support Arrays in browserify confΒ defunctzombie/zuul#280.test-xxx
). Together with the fact that quite a few tests can only work innode
(usingfs
,http.createServer
and such) makes that the subset of tests that can be run in the browser is not as big as one would hope. Rewriting some of the tests + adding new ones would be ideal, but not sure it's super worth considering that we are looking forward to the Mocha's rewrite. Still, those tests could likely be ported to the rewrite, not so bad I guess...Feedback is welcome β looking forward to getting this done and rocking the of the issues/PRs!