Open timrwood opened 9 years ago
paging @rwjblue (he's our area expert around theses topics)
Ideally, the lib + tests could be build into one file via broccoli and run in a browser and node without these browser*.js files.
Generally, I think that's the way to go. Write both tests and lib code using es6, transpile to amd, cjs, and globals[1]. Run amd and globals tests in a browser, run cjs tests via node. Broccoli seems like a good choice. There are a lot of es6->es5 module transpilers, but I've mostly used https://github.com/esnext/es6-module-transpiler. @eventualbuddha probably has good advice here?
[1] Although I know you want to move away from globals I feel obligated to lobby on their behalf for the huge community of JS developers for whom modules is a deep mystery. cc @searls
And I'm not exactly a fan of QUnit, but it works very reliably.
This is mostly done, just need to extract common locale tests.
Travis link here. https://travis-ci.org/timrwood/moment-es6
Well, now the fun part: bikeshedding what the next public API should be!
Well, after a huge refactoring this weekend, things are looking good.
Code is spread across ~80 small modules in the lib folder.
The bundled output is able to be tested using npm test
, and the transpiled commonjs modules are able to be tested using npm run test-all
.
Definitely still some work to be done refactoring and organizing files, but its-happening.gif.
@timrwood I'd recommend switching to either 6to5's module transpilation or, since you're using the bundle format, use http://esperantojs.org/ which has a better bundler than the es6-module-transpiler and is much faster.
@eventualbuddha thanks for the tip, I wasn't aware of esperanto.
Right now, we are using nodeunit to run tests in node + browsers.
In order to run tests, nodeunit will run any method on
module.exports
as a test.With the es6 module transpiler, we could define tests like so.
Nodeunit runs through every cjs module in a directory and runs the tests on its exports. This works pretty well, but I'm not sure how we will be able to iterate over all these files once they are transpiled in order to run them in the browser.
I'm wondering if we would need to switch to another test framework that isn't so node specific. QUnit perhaps?
Then, test files would look something more like so.
Ideally, the lib + tests could be build into one file via broccoli and run in a browser and node without these browser*.js files.
Thoughts @trek?