Skip to content

Commit ec96a86

Browse files
committed
Add changelog entry for 4.0.0
1 parent 6b46717 commit ec96a86

1 file changed

Lines changed: 38 additions & 40 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,47 @@
11
# Change Log
22

3-
## Unreleased
4-
5-
* Fix a CommonJS module loaded with `import()` having empty exports when the
6-
test file had already called `td.replace()` (Node 20.6–24.17 and 25.x), by
7-
updating quibble to 0.13.0
8-
[quibble#111](https://github.com/testdouble/quibble/issues/111)
9-
* **Behavior change:** importing an ES module that doesn't exist, and that
10-
isn't replaced with `td.replaceEsm()`, now fails with Node's usual
11-
`ERR_MODULE_NOT_FOUND` instead of `ENOENT`. This includes importing a module
12-
that only existed as a replacement after `td.reset()`. Tests that check for
13-
`ENOENT` (or its message) need updating
14-
[quibble#100](https://github.com/testdouble/quibble/issues/100)
15-
* Fix webpack 5 browser builds failing with `Can't resolve 'module'` (broken
16-
since 3.20.1). testdouble no longer pulls Node's `module` or `events` into
17-
browser bundles. In a browser, `td.replaceEsm()` now throws a clear
18-
"only supported under Node.js" error, and `td.listReplacedModules()` returns
19-
`[]` [#531](https://github.com/testdouble/testdouble.js/issues/531)
20-
* Add an ES module build for browsers, so `import * as td from 'testdouble'`
21-
works in tools that load native ES modules, like @web/test-runner. Tools that
22-
resolve with the `browser` export condition get `dist/testdouble.mjs`. Webpack,
23-
Vite and esbuild apply it when targeting the browser; @web/test-runner needs
24-
`nodeResolve: { exportConditions: ['browser', 'development'] }` in its config.
3+
## 4.0.0
4+
5+
* **Breaking change:** drop support for Node.js versions before 22, all of
6+
which have reached end-of-life
7+
* Fix getters being imitated as `undefined` by `td.replace(path)`, `td.object`,
8+
`td.constructor` and `td.imitate`. This made every export of an SWC-compiled
9+
module, and re-exports compiled by Babel or `tsc`, impossible to stub
10+
[#526](https://github.com/testdouble/testdouble.js/issues/526)
11+
[#550](https://github.com/testdouble/testdouble.js/pull/550)
12+
* Fix `td.replace(object, 'property')` throwing `Cannot set property ... which
13+
has only a getter` on a getter with no setter. It now replaces the getter,
14+
and `td.reset()` restores it. A getter that can't be redefined, as SWC
15+
defines exports, gets an error suggesting `td.replace('path/to/module')`
16+
[#526](https://github.com/testdouble/testdouble.js/issues/526)
17+
[#550](https://github.com/testdouble/testdouble.js/pull/550)
18+
* Fix webpack 5 browser builds failing with `Can't resolve 'module'`, broken
19+
since 3.20.1. In a browser, `td.replaceEsm()` now throws an "only supported
20+
under Node.js" error, and `td.listReplacedModules()` returns `[]`
21+
[#531](https://github.com/testdouble/testdouble.js/issues/531)
22+
* Add an ES module build for browsers, `dist/testdouble.mjs`, so
23+
`import * as td from 'testdouble'` works in tools that load native ES
24+
modules. Tools resolving with the `browser` export condition get it: webpack,
25+
Vite and esbuild do when targeting the browser, and @web/test-runner does
26+
with `nodeResolve: { exportConditions: ['browser', 'development'] }`.
2527
`testdouble/dist/testdouble.js` can be imported by path again
2628
[#494](https://github.com/testdouble/testdouble.js/issues/494)
27-
* **Behavior change:** any `import` of testdouble resolved with the `browser`
29+
* Fix a CommonJS module loaded with `import()` having empty exports after the
30+
test file called `td.replace()` (Node 20.6–24.17 and 25.x), by updating
31+
quibble to 0.13.0 [quibble#111](https://github.com/testdouble/quibble/issues/111)
32+
* **Behavior change:** imitating an object now calls its getters, so their side
33+
effects run. Getters that throw, getters on prototypes (as `td.constructor`
34+
reads them), and getters nested more than 3 deep still give `undefined`
35+
[#526](https://github.com/testdouble/testdouble.js/issues/526)
36+
* **Behavior change:** an `import` of testdouble resolved with the `browser`
2837
condition now gets the browser build, which can't replace modules. That
29-
includes Jest's jsdom environment with `--experimental-vm-modules`, and Node
38+
includes Jest's jsdom environment with `--experimental-vm-modules` and Node
3039
run with `--conditions=browser`. `require('testdouble')` is unaffected
31-
* Fix getter properties coming out of `td.imitate` as `undefined`. This affected
32-
`td.replace(path)` (including through testdouble-jest), `td.object`,
33-
`td.constructor` and `td.imitate`. Most visibly, every export of a module
34-
compiled by SWC, and re-exports compiled by Babel or `tsc`, couldn't be
35-
stubbed [#526](https://github.com/testdouble/testdouble.js/issues/526)
36-
* Fix `td.replace(object, 'property')` throwing `Cannot set property ... which
37-
has only a getter` when the property is a getter with no setter. It now
38-
replaces the getter, and `td.reset()` restores the original getter. A getter
39-
that can't be redefined (as SWC defines exports) gets an error that suggests
40-
`td.replace('path/to/module')` instead
41-
[#526](https://github.com/testdouble/testdouble.js/issues/526)
42-
* **Behavior change:** when imitating an object, testdouble now calls its
43-
getters and imitates what they return, instead of using `undefined`. Any side
44-
effects of those getters now run. Getters that throw, getters on prototypes
45-
(like those `td.constructor` reads), and getters nested more than 3 deep still
46-
give `undefined`
40+
[#494](https://github.com/testdouble/testdouble.js/issues/494)
41+
* **Behavior change:** importing a missing ES module that isn't replaced, such
42+
as one that only existed as a replacement before `td.reset()`, now fails with
43+
`ERR_MODULE_NOT_FOUND` instead of `ENOENT`. Update tests that check for
44+
`ENOENT` [quibble#100](https://github.com/testdouble/quibble/issues/100)
4745

4846
## 3.23.0
4947

0 commit comments

Comments
 (0)