Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test parameterization variable binding #506

merged 3 commits into from Apr 9, 2019


None yet
4 participants
Copy link

sohkai commented Apr 8, 2019

Oops, previously some parameterized tests would only run the last parameterization repeatedly.

Learning: We (especially me 馃槄) should remember to ALWAYS bind the parameterized variables locally when doing this type of parameterization. This can be done easily by using const or let in the for/of declaration, or doing it locally inside the block.

Using a var declaration (default) causes things to break because Mocha does two passes on the tests:

  1. Collect test cases by running everything not in a test hook (e.g. before(), beforeEach(), it(), etc.)
  2. Actually run the test cases.

Because of this, any for loop's var declaration will run through 1 (collection), and always end up as the array's last item when 2 (test running) starts.

Thanks to @osarrouy for noticing this 馃槃.

@sohkai sohkai requested review from izqui, bingen and facuspagnuolo Apr 8, 2019


This comment has been minimized.

Copy link

facuspagnuolo commented Apr 8, 2019

Good to know :)


This comment has been minimized.

Copy link

coveralls commented Apr 8, 2019

Coverage Status

Coverage remained the same at 99.54% when pulling 834d343 on test-fix-parameterization into 76addef on dev.


bingen approved these changes Apr 9, 2019

Copy link

bingen left a comment

Thanks @sohkai and @osarrouy !

@sohkai sohkai merged commit bef0141 into dev Apr 9, 2019

5 checks passed

License Compliance All checks passed.
continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed
coverage/coveralls Coverage remained the same at 99.54%
license/cla Contributor License Agreement is signed.

@sohkai sohkai deleted the test-fix-parameterization branch Apr 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.