Skip to content

Exercise both polyfill and native fetch in test suite - #258

Merged
mislav merged 9 commits into
JakeChampion:masterfrom
mislav:exercise-polyfill
Jan 18, 2016
Merged

mislav merged 9 commits into
JakeChampion:masterfrom
mislav:exercise-polyfill

Conversation

@mislav

@mislav mislav commented Jan 10, 2016

Copy link
Copy Markdown
Contributor

Before, in browsers that had native fetch implementation the polyfill code was never exercised by the test suite. This ensures that both implementations are exercised.

Bonus features: better first-run experience when cloning the project and trying to run script/server:

  • The port number is now printed on stderr;
  • Test suite now renders at root path / instead of having to type out /test/test.html;
  • Helpful error message is displayed if you forgot to run make.

@dgraham

dgraham commented Jan 10, 2016

Copy link
Copy Markdown
Contributor

๐Ÿšข

@mislav

mislav commented Jan 10, 2016

Copy link
Copy Markdown
Contributor Author

This is not yet ready. Locally I've upgraded mocha to get access to skip() test or suite at runtime, as opposed to definition time, but the feature doesn't work as advertised. I'll need more time.

If someone just cloned this project, they might be tempted to
`script/server` and try to run the test suite immediately. That won't
work, because they have to run `make` first to obtain all npm and bower
dependencies. However, they would get a blank HTML page which would be
confusing because it's not immediately apparent what they did wrong.

Now, an error message is rendered that suggests you should run `make`.
Before, in browsers that had native `fetch` implementation the polyfill
code was never exercised by the test suite. This ensures that both
implementations are exercised.
This is opposed to checking for native ArrayBuffer because the polyfill
will only define `arrayBuffer()` methods if Blob is available.
@mislav

mislav commented Jan 14, 2016

Copy link
Copy Markdown
Contributor Author

@dgraham This is now ready for another ๐Ÿ‘€, thanks. I've also brought in the Firefox fix from #157 because JSON parsing exception somehow caused cascading failure in Mocha test output, ruining the rest of HTML rendering and causing failures in unrelated tests.

@dgraham

dgraham commented Jan 16, 2016

Copy link
Copy Markdown
Contributor

I've also brought in the Firefox fix from #157 because JSON parsing exception somehow caused cascading failure in Mocha test output

In general, I'm not a fan of patching production code to accommodate the test suite. Is there another way the tests can avoid this problem?

Comment thread package.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt you define min-versions instead of fixed ones, e.g. Using caret operator ^?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, but in this case I don't want jshint dependency to move around at all, lest its behavior suddenly changes, causing failures in CI for unsuspecting contributors and their pull requests.

@mislav

mislav commented Jan 16, 2016

Copy link
Copy Markdown
Contributor Author

Is there another way the tests can avoid this problem?

We could skip the test in the case we're testing with Firefox and we're exercising the polyfill code. Is that what you would want?

It feels weird, because we're skipping the test because of a Firefox bug, when we can easily fix the bug.

@dgraham

dgraham commented Jan 17, 2016

Copy link
Copy Markdown
Contributor

Skipping this test in Firefox sounds good to me. We're testing the native implementations only to ensure our polyfill behavior matches. We're covered in that case with Chrome.

When exercising the polyfill in Firefox, the invalid JSON parsing error
will cripple the test suite, causing cascading failures in Mocha HTML
output as well as cause failures in unrelated tests.

The code fix was proposed #157 but we decided not to pull it since it's
a Firefox bug and Firefox now ships with native fetch anyway. Instead,
we avoid running that test as part of our polyfill test suite.
mislav added a commit that referenced this pull request Jan 18, 2016
Exercise both polyfill and native `fetch` in test suite
@mislav
mislav merged commit 4e00ced into JakeChampion:master Jan 18, 2016
@mislav
mislav deleted the exercise-polyfill branch January 18, 2016 09:32
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants