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

Cannot find module issue with mocha.js in browser #3091

Closed
killmenot opened this issue Nov 3, 2017 · 5 comments
Closed

Cannot find module issue with mocha.js in browser #3091

killmenot opened this issue Nov 3, 2017 · 5 comments
Assignees
Labels
type: bug a defect, confirmed by a maintainer

Comments

@killmenot
Copy link

Hi,

I'm using mocha with requirejs for browser testing and got a weird issue when updated to 4.0.1.

By some reason I got the following issue when run tests:
screenshot 2017-11-03 20 26 37

You can find the code that reproduce the issue here: https://github.com/killmenot/mocha-cannot-find-module-issue (just do npm install and then open testrunner.html in browser or run npm run test)

I took a look at mocha.js (I run make mocha.js) I found the following:
screenshot 2017-11-03 20 28 40

When I remove require= from mocha.js file the test works fine.

Any advices?

@ScottFreeCode ScottFreeCode added the type: bug a defect, confirmed by a maintainer label Nov 7, 2017
@ScottFreeCode
Copy link
Contributor

Someone will have to figure out whether our Browserify options changed or if the Browserify defaults changed in the newer version and either way how to change it back with the version we now use.

(At some point, we need to get tests using Karma with an AMD loader such as RequireJS so that these get caught before releasing...)

@boneskull
Copy link
Member

Yes, I added --require buffer:buffer which evidently broke stuff.

@boneskull boneskull self-assigned this Dec 12, 2017
boneskull added a commit that referenced this issue Dec 12, 2017
This became too difficult to manage on the command-line.

What we're trying to do here is ship a version of the `Buffer` shim
which plays well with IE9/IE10.  Browserify ships with a version which
does NOT play well, meaning we have to force it to use the version
we choose (`buffer@4.9.x`).

The fix is in two parts:

1.  `insertGlobalVars` option replaces usages of global `Buffer` with
`require('/path/to/mocha/node_modules/buffer').Buffer`
2.  Any *other* module which explicitly requires `buffer` or, yes,
`buffer/`, must *also* use `/path/to/mocha/node_modules/buffer`

If *both* of these are not in place, Browserify will use its *own*
version of the `buffer` shim.
@boneskull
Copy link
Member

@killmenot please pull down PR #3145 to test a fix

boneskull added a commit that referenced this issue Dec 12, 2017
This became too difficult to manage on the command-line.

What we're trying to do here is ship a version of the `Buffer` shim
which plays well with IE9/IE10.  Browserify ships with a version which
does NOT play well, meaning we have to force it to use the version
we choose (`buffer@4.9.x`).

The fix is in two parts:

1.  `insertGlobalVars` option replaces usages of global `Buffer` with
`require('/path/to/mocha/node_modules/buffer').Buffer`
2.  Any *other* module which explicitly requires `buffer` or, yes,
`buffer/`, must *also* use `/path/to/mocha/node_modules/buffer`

If *both* of these are not in place, Browserify will use its *own*
version of the `buffer` shim.
boneskull added a commit that referenced this issue Dec 12, 2017
- this will assert that using `import` with `mocha.js` does not break
- fix: remove missing `Makefile` target; add `test-browser-esm` target
- fix: update invalid comments regarding running SauceLabs locally in
  `karma.conf`
- fix: break if attempting to run Karma on AppVeyor
- refactor Karma test flags to all use `MOCHA_TEST` env var
- a few reformats

Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
@killmenot
Copy link
Author

@boneskull PR #3145 fixes this issue. Thank you

@Bamieh
Copy link
Contributor

Bamieh commented Jan 9, 2018

closing this as it is fixed by dropping ie9 and ie10 support (fixed by #3164)

@Bamieh Bamieh closed this as completed Jan 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants