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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockableSystemJS Library #1467

Open
dchambers opened this issue Jul 24, 2015 · 1 comment
Open

MockableSystemJS Library #1467

dchambers opened this issue Jul 24, 2015 · 1 comment

Comments

@dchambers
Copy link
Contributor

So that we can switch from browser-modules to SystemJS we will need a MockableSystemJS library that allows modules to be replaced for the duration of a test.

@dchambers
Copy link
Contributor Author

It's worth pointing out that we may never use any of this infrastructure (MockableSystemJS, MockableSystemJS Wrapper Library or sub-realms compatibility layer) for any of the BRJS or CT libraries given that we plan to move those to NPM within the same time frame, given that browserify and webpack are more mature module systems than systemjsify.

This is especially the case since we don't yet know whether the proposed mocking system would work when used with the version of SystemJS that works natively on Node.js — this would be required so we could run our tests on both Node.Js and the browser, and may well cause additional work for us that we can otherwise avoid.

These are the mocking options if we are going to use a different module system:

Node.Js Module Mocking:

  1. proxyquire (pairs with proxyquireify)
  2. rewire (pairs with rewire-webpack)
  3. mockery

Browserify Module Mocking:

  1. proxyquireify / proxyquire-universal
  2. browserify-mockify

WebPack Module Mocking:

  1. rewire-webpack
  2. inject-loader
  3. enhanced-require (unmaintained)

Since we like to run our tests on both Node.js and the browser, proxyquire and rewire would appear to be the best options for us.

OTOH, libraries that need to require non JavaScript resources (e.g. HTML templates or CSS) won't be able to use browserify because it doesn't support non JavaScript assets, and won't be able to use webpack, since its plugin require syntax is incompatible with SystemJS.

Such libraries could run their tests using systemjsify on the browser alone, or might be able to run in Node.Js if it just happens to work anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants