QubitProducts / slapdash

A lightweight JavaScript utility belt with native method override protection
http://npmjs.org/packages/slapdash
MIT License
3 stars 1 forks source link

Fix tests #56

Closed alanclarke closed 6 years ago

alanclarke commented 6 years ago

Slapdash was previously only ever running tests on the native build.

This was because of an off-by-one error that meant that none of the native methods were actually getting overridden.

Also a number of the native methods that should have been overridden were missing from the list - I populated the missing ones in this pr.

After solving the above, it still didn't work.

Turns browserify does not work the way this code assumed it did, it does not create a bundle per file registered in the karma conf like karma-webpack would. Instead browserify combines all files into one bundle.

Because all the files are in one bundle each file is evaluated exactly once and so whichever suite you load first invalidates the next.

To get around this, I've introduced SLAPDASH_FILES env variable to enable you to specify which suite you want to run from the command line, and updated the test commands to run main, polyfil and native suites as separate sequential karma builds.

The entry files are a bit repetitive and could probably do with a loop but I didn't do that because jim hinted that browserify wouldn't play nice with dynamic requires and I didn't want to take on more battles than I already had