mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
34 lines
682 B
Markdown
34 lines
682 B
Markdown
|
# Enforce having return statement when testing with promises (valid-expect-in-promise)
|
||
|
|
||
|
Ensure to return promise when having assertions in `then` or `catch` block of
|
||
|
promise
|
||
|
|
||
|
## Rule details
|
||
|
|
||
|
This rule triggers a warning if,
|
||
|
|
||
|
- test is having assertions in `then` or `catch` block of a promise
|
||
|
- and that promise is not returned from the test
|
||
|
|
||
|
### Default configuration
|
||
|
|
||
|
The following pattern is considered warning:
|
||
|
|
||
|
```js
|
||
|
it('promise test', () => {
|
||
|
somePromise.then(data => {
|
||
|
expect(data).toEqual('foo');
|
||
|
});
|
||
|
});
|
||
|
```
|
||
|
|
||
|
The following pattern is not warning:
|
||
|
|
||
|
```js
|
||
|
it('promise test', () => {
|
||
|
return somePromise.then(data => {
|
||
|
expect(data).toEqual('foo');
|
||
|
});
|
||
|
});
|
||
|
```
|