Skip to content

Commit fefe1f5

Browse files
committed
refactor(config): simplify test inheritance imports and cases
1 parent e87e496 commit fefe1f5

2 files changed

Lines changed: 37 additions & 29 deletions

File tree

‎packages/rstack/src/rstestConfig.ts‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,23 @@ const resolveAutomaticExtends = async (
1414
// Prefer the app when both app and lib are defined. Merging both adapters can
1515
// introduce conflicting runtime, resolve, and source transform settings.
1616
if (layers.some((layer) => layer.app !== undefined)) {
17-
const [{ withRsbuildConfig }, { resolveRsbuildConfig }] = await Promise.all(
18-
[
19-
import(
20-
/* rspackChunkName: 'adapterRsbuild' */
21-
'@rstest/adapter-rsbuild'
22-
),
23-
import('./rsbuildConfig.ts'),
24-
],
17+
const { withRsbuildConfig } = await import(
18+
/* rspackChunkName: 'adapterRsbuild' */
19+
'@rstest/adapter-rsbuild'
2520
);
21+
const { resolveRsbuildConfig } = await import('./rsbuildConfig.ts');
2622

2723
return withRsbuildConfig({
2824
config: await resolveRsbuildConfig(layers, params),
2925
});
3026
}
3127

3228
if (layers.some((layer) => layer.lib !== undefined)) {
33-
const [{ withRslibConfig }, { resolveRslibConfig }] = await Promise.all([
34-
import(
35-
/* rspackChunkName: 'adapterRslib' */
36-
'@rstest/adapter-rslib'
37-
),
38-
import('./rslibConfig.ts'),
39-
]);
29+
const { withRslibConfig } = await import(
30+
/* rspackChunkName: 'adapterRslib' */
31+
'@rstest/adapter-rslib'
32+
);
33+
const { resolveRslibConfig } = await import('./rslibConfig.ts');
4034

4135
return withRslibConfig({
4236
config: await resolveRslibConfig(layers, params),

‎packages/rstack/tests/config/test-merge.test.ts‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,32 @@ test('inherits merged lib config when no layer defines app', async () => {
9999
});
100100
});
101101

102-
test.each([
103-
{ extends: undefined },
104-
{ projects: ['./external.config.ts', { name: 'explicit', extends: {} }] },
105-
])(
106-
'skips build config factories when inheritance is disabled: %j',
107-
async (testConfig) => {
108-
const build = rs.fn(() => ({}));
109-
await resolveRstestConfig(
110-
[{ app: build, lib: build, test: { retry: 1 } }, { test: testConfig }],
111-
params,
112-
);
102+
test('skips build config factories when the root explicitly defines extends', async () => {
103+
const build = rs.fn(() => ({}));
104+
await resolveRstestConfig(
105+
[
106+
{ app: build, lib: build, test: { retry: 1 } },
107+
{ test: { extends: undefined } },
108+
],
109+
params,
110+
);
111+
112+
expect(build).not.toHaveBeenCalled();
113+
});
114+
115+
test('skips build config factories when no project needs automatic inheritance', async () => {
116+
const build = rs.fn(() => ({}));
117+
await resolveRstestConfig(
118+
[
119+
{ app: build, lib: build, test: { retry: 1 } },
120+
{
121+
test: {
122+
projects: ['./external.config.ts', { name: 'explicit', extends: {} }],
123+
},
124+
},
125+
],
126+
params,
127+
);
113128

114-
expect(build).not.toHaveBeenCalled();
115-
},
116-
);
129+
expect(build).not.toHaveBeenCalled();
130+
});

0 commit comments

Comments
 (0)