Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "esmock", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"license": "MIT", | ||
@@ -17,2 +17,4 @@ "readmeFilename": "README.md", | ||
"esm", | ||
"mjs", | ||
"unit-test", | ||
"esmock", | ||
@@ -19,0 +21,0 @@ "es6", |
esmock | ||
====== | ||
**(c)[Bumblehead][0]** | ||
[![npm version](https://badge.fury.io/js/esmock.svg)](https://badge.fury.io/js/esmock) [![Build Status](https://travis-ci.org/iambumblehead/esmock.svg?branch=master)](https://travis-ci.org/iambumblehead/esmock) | ||
This package **must be used with node's experimental --loader,** | ||
``` bash | ||
ava --node-arguments="--loader=esmock" | ||
mocha --loader=esmock | ||
``` | ||
This package **must be used with "module" type packages.** Add the type to your package.json, | ||
**esmock _must_ be used with node's experimental --loader** | ||
``` json | ||
{ | ||
"name": "my-module", | ||
"name": "give-esmock-a-star", | ||
"type": "module", | ||
"scripts" : { | ||
"unit-test": "ava --node-arguments=\"--loader=esmock\"" | ||
"unit-test-ava": "ava --node-arguments=\"--loader=esmock\"", | ||
"unit-test-mocha": "mocha --loader=esmock" | ||
} | ||
@@ -28,3 +19,3 @@ } | ||
And use it | ||
**Use it** `await esmock( './path/to/module.js', childmocks, globalmocks )` | ||
``` javascript | ||
@@ -45,11 +36,7 @@ import test from 'ava'; | ||
test('should apply third parameter "global" definitions', async t => { | ||
const main = await esmock('./local/main.js', { | ||
'./local/mainUtil.js' : { | ||
exportedFunction : () => 'foobar' | ||
} | ||
}, { | ||
test('should do "global" instance mocks (third parameter)', async t => { | ||
const { getFile } = await esmock('./local/main.js', {}, { | ||
fs : { | ||
readFileSync : () => { | ||
return 'this value anywhere the instance imports fs, global'; | ||
return 'this anywhere your instance imports fs for readFileSync'; | ||
} | ||
@@ -59,4 +46,3 @@ } | ||
const tplStr = main.readTemplateFile(); | ||
t.is(tplStr, 'this value anywhere the instance imports fs, global'); | ||
t.is(getFile(), 'this anywhere your instance imports fs for readFileSync'); | ||
}); | ||
@@ -68,9 +54,12 @@ ``` | ||
* 0.3.1 _Apr.12.2021_ | ||
* simplify README | ||
* 0.3.0 _Apr.10.2021_ | ||
* adds support for mocking modules 'globally' for the instance | ||
* 0.2.0 _Apr.10.2021_ | ||
* adds support for mocking core modules such as fs and path | ||
* 0.1.0 _Apr.10.2021_ | ||
* adds support for native esm modules | ||
* 0.2.0 _Apr.10.2021_ | ||
* adds support for mocking core modules such as fs and path | ||
* 0.3.0 _Apr.10.2021_ | ||
* adds support for mocking modules 'globally' for the instance | ||
[0]: http://www.bumblehead.com "bumblehead" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23954
62