gulp-cli
gulp-cli copied to clipboard
Tests for extension lookups
While thinking about https://github.com/gulpjs/gulp-cli/pull/214#issuecomment-637921048
I realized I also needed to add the .mjs
extension to the 1.x and 2.x release streams of interpret
, but all the tests were passing for gulp-cli
.
I think this is due to us using --gulpfile
for all our tests. @sttk do you know a way to test for the extensions?
@phated Extension tests are executed in a Liftoff's test. That is test/lib/register_loader.js
.
The explanation of the test is as follows:
- Creates loader mock for each extension. It returns a loading message with a loaded file name and the loader name.
- Sets a
loader:success
event handler to a sample Liftoff app, and verifies the loading message in the event handler. - Executes
registerLoader
withextensions
option which has only a pair of target extension and the loader mock.
@sttk with the completion of #214, a file with .mjs
extension does not use the loaders as handled by liftoff because is uses import(gulpfilePath)
. That's why I think we need to include tests for loading by extension in this project.
@phated Sorry. I didn't look detail of #214, and I assumed that the dynamic import function was used like require
with being associated with .mjs
. But the merged way is better according to interpret#68, indeed.
@sttk I'm thinking about our APIs for the next major version and maybe rechoir
can become an abstraction over require
/import()
like was added in #214 - it might even be able to handle "loader extensions" that the node.js team is working on for import