Skip to content

Commit

Permalink
shorten readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed May 8, 2021
1 parent dd2f470 commit 315635f
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ import esmock from 'esmock';
test('should mock modules and local files at same time', async t => {
const main = await esmock('../src/main.js', {
stringifierpackage : o => JSON.stringify(o),
'../src/hello.js' : {
default : () => 'world'
},
'../src/util.js' : {
exportedFunction : () => 'foobar'
}
});

t.is(main(), JSON.stringify({ test : 'foobar' }));
t.is(main(), JSON.stringify({ test : 'world foobar' }));
});

test('should do global instance mocks —third parameter', async t => {
Expand All @@ -43,28 +46,9 @@ test('should do global instance mocks —third parameter', async t => {

t.is(getFile(), 'anywhere the instance uses fs readFileSync');
});

test('some mock definitions need a "default" namespace', async t => {
const { hello } = await esmock('../src/main.js', {}, {
'../src/hello.js' : {
default : {
world: () => 'world'
}
}
});

t.is(hello(), 'world');
});
```


### notes

Use `--loader=esmock --no-warnings` to suppress node's warning messages.

If your mock definition isn't appearing in tests, try nesting it inside a default definition.


### changelog

* 0.3.9 _May.05.2021_
Expand Down

0 comments on commit 315635f

Please sign in to comment.