Skip to content

Support a nicer way of mocking shim modules when using dojo/testing #275

@matt-gadd

Description

@matt-gadd

Enhancement
Currently their is no canonical way to mock @dojo/shim modules. This is a little annoying when wanting to mock things such as fetch and requires messing with the global.

Perhaps inside our shim modules we can have a wrapper that wraps the shim itself and when a test has flag is enabled provides an additional export that allows you to mutate it.

For example something like:

import fetch, { replace } from '@dojo/framework/shim/fetch'
replace(myMockFetch);

where replace (not attached to the name), is only available with the test has flag. This would allow you to swap the implementation.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions