Skip to content

Commit d410016

Browse files
committed
updated: readme caveat
1 parent 860ee3a commit d410016

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
- Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
44
- Adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
55

6+
7+
## [1.0.1] - 2024-07-12
8+
9+
### Fixed
10+
11+
- Updated README with Caveat section
12+
613
## [1.0.0] - 2024-07-10
714

815
### Added

README.md

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# jest-to-log
22

3-
# What
3+
## What
44

55
Test log messages with [`jest`](https://jestjs.io/)
66

7-
# Why?
7+
## Why?
88

99
Grown out of the need to test `console.log/error` messages or writes to `process.stdout/stderr` in my cli-facing apps. Note: this is not a full-blown cli-testing tool, but a check for important log messages from your app that's tested with jest.
1010

11-
# Usage
11+
## Usage
1212

1313
```javascript
1414
require("jest-to-log");
1515
//or
1616
import "jest-to-log";
1717
```
1818

19-
# Example
19+
## Example
2020

2121
```javascript
2222
//in jest test file
@@ -36,8 +36,21 @@ describe("toLog", () => {
3636
});
3737
});
3838
```
39+
## Caveat
40+
- When using with typescript (i.e., `ts-jest` and `@types/jest`), it's advised to explicitly import the `expect` from `@jest/globals` to avoid type conflicts:
3941

40-
# Matchers
42+
```javascript
43+
//test.ts
44+
45+
import {expect} from "@jest/globals"
46+
47+
// ...your test
48+
```
49+
50+
- Do NOT set the `injectGlobals` jest option to `false`, or else a `ReferenceError` will be thrown. This is because the matchers are extended onto the `expect` object _without_ importing it from `@jest/globals`.
51+
52+
53+
## Matchers
4154

4255
| Matcher Name | Description |
4356
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -46,18 +59,20 @@ describe("toLog", () => {
4659
| `toLogStderr ` | Checks if a function **explicitly** write to `process.stderr`. Cannot be used to capture `console.error/warn` calls due to the custom console implementation of `jest`. |
4760
| `toLogErrorOrWarn` | Checks if a function logs an error or warning via `console.error()` or `console.warn()`, respectively. |
4861

49-
# Installation
62+
63+
64+
## Installation
5065

5166
`$ npm install jest-to-log`
5267

53-
# Requirements
68+
## Requirements
5469

55-
- `Jest`
70+
- Latest versions of `Jest` recommended
5671

57-
# Dependencies
72+
## Dependencies
5873

5974
- **0 javascript/nodejs dependency!**
6075

61-
# Test
76+
## Test
6277

6378
`$ npm test`

0 commit comments

Comments
 (0)