Testing Goog Modules¶

When referencing a Closure or ES module in a test, the goog.module.get call must be used to retrieve the exports. This call should be made within a closure such as the describe function. The test will also need to use a bare goog.require on the module ID from goog.declareModuleId or goog.module.

// this test file is not a module, so
// const SomeModule = goog.require('package.SomeModule');
// will not work
goog.require('package.SomeModule');

describe('package.SomeModule', () => {
  const {default: SomeModule} = goog.module.get('package.SomeModule');

  it('should do stuff...', () => {
  });
});