Files
Sebastian "Sebbie" SilbermannandClaude Code 2dc7da790d [test] Bump Jest to 30.4 (#37382)
Bumps Jest to latest 30.x

The `resolutions` pin that kept jsdom at 22.1.0 is removed, so the test
environment now runs the jsdom version that jest-environment-jsdom
declares (26.1.0 on Jest 30).

The matcher aliases that Jest 30 deleted are replaced with their
canonical forms across the test suites: `toBeCalled`, `toBeCalledTimes`,
`toBeCalledWith`, and `lastCalledWith` become the corresponding
`toHaveBeenCalled*` matchers, and `toThrowError` becomes `toThrow`. The
custom `toThrow` matcher override is removed in the PR below this one.

Jest 30 activates the `node` export condition for CommonJS requires in
every test environment, so in the jsdom-based Flight suites
`react-server-dom-webpack/client` now resolves to the Node build (which
requires an options argument) instead of the browser build. Those suites
now map the client entry to `client.browser` explicitly, matching the
existing mocks for the `server` and `static` entries, and the Turbopack
Node test uses `jest.requireActual` because `client` and `client.node`
now resolve to the same file, which otherwise made the mock factory
recurse. For the same reason `react-dom/static` resolves to the
lazily-initialized Node entry in source mode, so its version-mismatch
test is gated to build mode like the other server-entry tests.

The obsolete `prettierPath` override is dropped from the base Jest
config because Jest 30 works with Prettier 3 for inline snapshots, which
also fixes `yarn test -u` crashing on the repo's Prettier 3-only hermes
plugin, and the now unused `prettier-2` alias dependency is removed with
it. Snapshot files are regenerated for Jest 30's updated snapshot header
and formatting. One test now passes a number instead of a string to
`jest.advanceTimersByTime`, which fake-timers v13 no longer coerces.

---------

Co-authored-by: Claude Code (kimi-k3[1m]) <noreply@anthropic.com>
2026-08-28 13:06:47 +02:00

35 lines
1.2 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const {evalStringConcat} = require('../evalToString');
const parser = require('@babel/parser');
const parse = source => parser.parse(`(${source});`).program.body[0].expression; // quick way to get an exp node
const parseAndEval = source => evalStringConcat(parse(source));
describe('evalToString', () => {
it('should support StringLiteral', () => {
expect(parseAndEval(`'foobar'`)).toBe('foobar');
expect(parseAndEval(`'yowassup'`)).toBe('yowassup');
});
it('should support string concat (`+`)', () => {
expect(parseAndEval(`'foo ' + 'bar'`)).toBe('foo bar');
});
it('should throw when it finds other types', () => {
expect(() => parseAndEval(`'foo ' + true`)).toThrow(/Unsupported type/);
expect(() => parseAndEval(`'foo ' + 3`)).toThrow(/Unsupported type/);
expect(() => parseAndEval(`'foo ' + null`)).toThrow(/Unsupported type/);
expect(() => parseAndEval(`'foo ' + undefined`)).toThrow(
/Unsupported type/
);
});
});