jest-webextension-mock
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "jest-webextension-mock", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Mock the components of a WebExtension", | ||
@@ -5,0 +5,0 @@ "main": "dist/setup.js", |
@@ -0,1 +1,3 @@ | ||
[![npm](https://img.shields.io/npm/v/jest-webextension-mock.svg)](https://www.npmjs.com/package/jest-webextension-mock) | [![npm](https://img.shields.io/npm/l/jest-webextension-mock.svg)](https://github.com/clarkbw/jest-webextension-mock/blob/master/LICENSE) | [![Twitter](https://img.shields.io/twitter/url/https/github.com/clarkbw/jest-webextension-mock.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D) | ||
---|--- | ||
@@ -16,4 +18,6 @@ ## Install | ||
## Usage | ||
## Setup | ||
### Require module directly | ||
In your `package.json` under the `jest` section add the `setupFiles` attribute with this module name. | ||
@@ -29,4 +33,6 @@ | ||
Alternatively you can create a setup file. | ||
### Use setup file | ||
Alternatively you can create a new setup file and require this module. | ||
`__setups__/chrome.js` | ||
@@ -47,2 +53,28 @@ ```js | ||
## Usage | ||
With this module setup in Jest you can start relying on it in your tests. | ||
```js | ||
describe('your function to test', () => { | ||
it('should have called a webextension API', () => { | ||
yourFunctionToTest(); | ||
expect(chrome.tabs.update).toHaveBeenCalled(); | ||
}); | ||
}); | ||
``` | ||
Check the API was called with certain parameters. | ||
```js | ||
describe('your function to test', () => { | ||
it('should have called a webextension API', () => { | ||
yourFunctionToTest(); | ||
expect(chrome.tabs.update).toHaveBeenCalledWith({ | ||
url: 'https://example.com/' | ||
}); | ||
}); | ||
}); | ||
``` | ||
## Development | ||
@@ -54,1 +86,19 @@ | ||
``` | ||
## Pull Request | ||
Before every PR run the following: | ||
``` | ||
yarn run prettier | ||
``` | ||
## Publish | ||
When publishing a new build, run the following: | ||
``` | ||
yarn run prettier | ||
yarn run build | ||
yarn publish | ||
``` |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
121178
17
0
101