Skip to content

Commit e5d2f01

Browse files
committed
test: execute the probe's missing-export filter, note the fixture pin coupling
The existing tests drove the runner with canned output, so nothing ran the filter the probe ships, and a green CI run does not either: the filter only reports, so breaking it makes every load pass. Verified by mutation, stubbing the filter to an empty list fails the new case. Also ties FIREBASE_RANGE to the firebase devDependency in a comment. They match today and nothing enforces it, so a move to firebase 12 would silently leave the probe exercising 11.
1 parent 774dde2 commit e5d2f01

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

‎scripts/entry-load.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export const DEFAULT_REACT_VERSIONS = ['18', '19'];
3737
// Held to the major the repo develops against rather than "latest", so the
3838
// fixture is deterministic and stays inside the declared peer range
3939
// (^9 || ^10 || ^11 || ^12).
40+
//
41+
// Keep this in step with the `firebase` devDependency in package.json. It
42+
// matches today, and nothing enforces that: when the repo moves to firebase 12
43+
// this fixture keeps loading the package against 11 and stays green, so the
44+
// major the probe actually exercises drifts away from the one CI develops
45+
// against without any signal.
4046
export const FIREBASE_RANGE = '^11.10.0';
4147

4248
// A load that resolves but exports nothing is still a broken package, and an

‎test/entry-load.test.mjs‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import fs from 'node:fs';
22
import os from 'node:os';
33
import path from 'node:path';
4-
import { collectFailures, describeResult, loadWithReact, parseProbeOutput } from '../scripts/entry-load.mjs';
4+
import { execFileSync } from 'node:child_process';
5+
import { EXPECTED_EXPORTS, collectFailures, describeResult, loadWithReact, parseProbeOutput, probeSource } from '../scripts/entry-load.mjs';
56

67
/**
78
* These tests pin the failure detection, not the fixture's shape. `publint` and
@@ -119,3 +120,43 @@ describe('loadWithReact', () => {
119120
expect(collectFailures([{ react: '18', ...result }])).toHaveLength(1);
120121
});
121122
});
123+
124+
/**
125+
* The tests above drive the runner with canned output, so none of them execute
126+
* the missing-export filter the probe actually ships. A green CI run does not
127+
* either: the filter only reports, so breaking it makes every load pass. These
128+
* run the generated source against a stand-in module instead of a mock.
129+
*/
130+
describe('probeSource', () => {
131+
let dir;
132+
133+
beforeEach(() => {
134+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'reactfire-probe-'));
135+
});
136+
137+
afterEach(() => {
138+
fs.rmSync(dir, { recursive: true, force: true });
139+
});
140+
141+
// The probe resolves its target by specifier, so a relative path stands in
142+
// for the installed package without needing a fixture install.
143+
function runProbe(exports) {
144+
fs.writeFileSync(path.join(dir, 'stand-in.mjs'), `export const ${exports.join(' = 1;\nexport const ')} = 1;\n`);
145+
fs.writeFileSync(path.join(dir, 'probe.mjs'), probeSource('esm', { name: './stand-in.mjs' }));
146+
return parseProbeOutput(execFileSync(process.execPath, [path.join(dir, 'probe.mjs')], { encoding: 'utf8' }));
147+
}
148+
149+
it('passes when every canary is exported', () => {
150+
const result = runProbe(EXPECTED_EXPORTS);
151+
expect(result.ok).toBe(true);
152+
});
153+
154+
// One dropped submodule is the case the widened canary list exists for, and
155+
// the case a broken filter would wave through.
156+
it('names the missing canary when one submodule is dropped', () => {
157+
const result = runProbe(EXPECTED_EXPORTS.filter((name) => name !== 'useStorageDownloadURL'));
158+
expect(result.ok).toBe(false);
159+
expect(result.reason).toBe('missing-exports');
160+
expect(result.missing).toEqual(['useStorageDownloadURL']);
161+
});
162+
});

0 commit comments

Comments
 (0)