-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I have a problem and two possible solutions, though I didn't peruse your code enough to determine which one is better..
I need to set a specific configuration for the module under test, like this:
describe('My component', function() {
beforeEach(function() {
requirejs.config({
config: {
'src/MyComponent': {
someVariable: true
}
}
});
});
it('should be able to read its own configuration', function(done) {
require(['isolate!src/MyComponent'], function(MyComponent) {
var comp = new MyComponent();
comp.getSomeVariable().should.be.true;
done();
});
});
});
Now, if the getSomeVariable method inside MyComponent needs to read from the module's configuration (using module().config) it would fail, since that configuration is not passed when the module is required through Isolate.
The solution seems to be simple: when setting the config here at line 178, the actual configuration of the module should be set too:
isolatedRequire = IsolationContext._require.config
context: isolatedContextName
baseUrl: mainCtx.config.baseUrl
config: ACTUALCONFIGURATIONHERE
What I'm not sure is whether we should pass mainCtx.config, or config.config. In my own test they seemed to contain pretty much the same data, which is why I'm not just opening a pull request... 😁
Metadata
Metadata
Assignees
Labels
No labels