Intern should provide an out-of-the-box solution for module mocking. The system should work with at least the Node loader and webpack, and it should provide type safety.
The mocking system currently used for Intern's self tests would probably work:
The snippet above dynamically imports a module, replacing certain of that modules imports with mock values. These imports are type safe, which is why the as any is required for the MockErrorFormatter mock, which doesn't completely mock ErrorFormatter.
The built in mocking system should be optional, and it shouldn't get in the way if the user wants to use something else.
Intern should provide an out-of-the-box solution for module mocking. The system should work with at least the Node loader and webpack, and it should provide type safety.
The mocking system currently used for Intern's self tests would probably work:
The snippet above dynamically imports a module, replacing certain of that modules imports with mock values. These imports are type safe, which is why the
as any
is required for the MockErrorFormatter mock, which doesn't completely mock ErrorFormatter.The built in mocking system should be optional, and it shouldn't get in the way if the user wants to use something else.