Skip to content

Commit 0f1eae9

Browse files
test: add NUT for missing npm install → DevServerError with install suggestion
Made-with: Cursor
1 parent b8123d6 commit 0f1eae9

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/commands/webapp/dev.nut.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616

1717
import { execSync } from 'node:child_process';
18+
import { writeFileSync } from 'node:fs';
19+
import { join } from 'node:path';
1820
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
1921
import { expect } from 'chai';
2022
import {
@@ -211,4 +213,32 @@ describe('webapp dev NUTs — Tier 2 CLI validation', () => {
211213

212214
expect(result.jsonOutput?.name).to.equal('DevServerUrlError');
213215
});
216+
217+
// ── Dev server startup errors ─────────────────────────────────
218+
219+
// Webapp created but npm install never run → dev server fails because
220+
// dependencies (e.g. vite) are not installed. The command should exit
221+
// with a meaningful error that suggests installing dependencies.
222+
// This mirrors the real user flow: generate → dev (without install).
223+
it('should suggest installing dependencies when dev server fails (no npm install)', () => {
224+
const projectDir = createProjectWithWebapp(session, 'noInstall', 'myApp');
225+
const appDir = webappPath(projectDir, 'myApp');
226+
227+
writeFileSync(
228+
join(appDir, 'package.json'),
229+
JSON.stringify({ name: 'test-webapp', scripts: { dev: 'vite' } })
230+
);
231+
writeManifest(projectDir, 'myApp', {
232+
dev: { command: 'npm run dev' },
233+
});
234+
235+
const result = execCmd(`webapp dev --name myApp --target-org ${targetOrg} --json`, {
236+
ensureExitCode: 1,
237+
cwd: projectDir,
238+
});
239+
240+
expect(result.jsonOutput?.name).to.equal('DevServerError');
241+
const output = JSON.stringify(result.jsonOutput ?? {});
242+
expect(output).to.match(/npm install|yarn install|dependencies/i);
243+
});
214244
});

0 commit comments

Comments
 (0)