Skip to content

Fix tests#193

Merged
benjamn merged 5 commits intofacebook:masterfrom
benjamn:use-populist-for-testing
Jul 15, 2013
Merged

Fix tests#193
benjamn merged 5 commits intofacebook:masterfrom
benjamn:use-populist-for-testing

Conversation

@benjamn
Copy link
Contributor

@benjamn benjamn commented Jul 15, 2013

This closes #155 and #154 and supersedes #177 and #156.

I wrote a new packaging tool called Populist that does everything we needed Browserify for (entry points, global variables, and of course module loading) but creates <script> tags for each module so that file names and line numbers will be correct in test output.

benjamn added 2 commits July 15, 2013 18:10
This will allow full support for mocking, dumpCache, and correct line
numbers in error messages.
Mocking happens only when config.constants.__MOCK__ is true.
bin/jsx Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still unnecessary but whatever 😉

benjamn added 3 commits July 15, 2013 19:41
We don't currently attempt to mock modules automatically, but we do
respect require("mock-modules").mock, .dontMock, and .dumpCache.

I'm going to keep investigating auto-mocking, since that would move us
much closer to the behavior used within Facebook.

Closes facebook#154.
Closes facebook#155.
When require("mock-modules").dumpCache() is called, all mock functions
previously created continue to refer to the old dirtyMocks array.

If we replace that array with a new one, those mock functions will never
have their .mockClear() methods called again.

The upstream version of mocks.js pulls a similar global trick, and I never
understood why until now.
No longer injecting __MOCK__ as a global constant (it's just a config
property now).

Turns out the `grunt jsx:debug` task was never necessary for tests.
benjamn added a commit that referenced this pull request Jul 15, 2013
@benjamn benjamn merged commit 558e8ca into facebook:master Jul 15, 2013
@benjamn benjamn deleted the use-populist-for-testing branch July 15, 2013 23:43
bvaughn pushed a commit to bvaughn/react that referenced this pull request Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable mocking of required modules during tests

2 participants