0

I'm using grunt-jasmine-nodejs and I have 3 specs that require the same file:

I have code like this:

$.platform = $.platform || {};
console.log($.platform.formSupport);
require('../runtime/platform/js/modules/platform.formSupport.js');
console.log($.platform.formSupport);

each file that console.log before and after require that file and I get only one instance (after first require) and the rest return undefined. How can I load same file multiple times in different specs?

jcubic
  • 61,973
  • 54
  • 229
  • 402

1 Answers1

0

I was able to fix this by unloading the module

var name = require.resolve('../runtime/platform/js/modules/platform.formSupport.js');
delete require.cache[name];

found in this answer

Community
  • 1
  • 1
jcubic
  • 61,973
  • 54
  • 229
  • 402