Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/wb/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ function getDefaultUnitTargets(project: Project): string[] | false {
return [];
}
if (project.hasVitest && fs.existsSync(path.join(project.dirPath, 'test'))) {
return ['test'];
return fs.existsSync(path.join(project.dirPath, 'test', 'e2e')) ? ['test', '--exclude', 'test/e2e/**'] : ['test'];
}
return false;
}
Expand Down
9 changes: 7 additions & 2 deletions packages/wb/src/scripts/execution/baseScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { buildShellCommand, buildShellEnvironmentAssignment } from '../../utils/
import type { ScriptArgv } from '../builder.js';
import { toDevNull } from '../builder.js';
import { dockerScripts } from '../dockerScripts.js';
import { drizzleScripts } from '../drizzleScripts.js';
import { prismaScripts } from '../prismaScripts.js';

export interface TestE2EOptions {
Expand Down Expand Up @@ -88,11 +89,15 @@ export abstract class BaseScripts {
ecosystemConfigPath === undefined
? [
`YARN wb buildIfNeeded ${argv.verbose ? '--verbose' : ''}`.trim(),
`node dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(),
`${project.isBunAvailable ? 'bun' : 'node'} dist/index.js ${argv.normalizedArgsText ?? ''}`.trim(),
]
: [project.buildCommand, `pm2-runtime start --no-autorestart ${ecosystemConfigPath}`];

return [...(project.hasPrisma ? prismaScripts.migrate(project).split('&&') : []), ...commands]
const migrationCommands = [
...(project.hasPrisma ? [prismaScripts.migrate(project)] : []),
...(project.hasDrizzle ? [drizzleScripts.migrate(project)] : []),
];
return [...migrationCommands.flatMap((cmd) => cmd.split('&&')), ...commands]
.filter(Boolean)
.map((cmd) => `${cmd} ${toDevNull(argv)}`.trim())
.join(' && ');
Expand Down
13 changes: 3 additions & 10 deletions packages/wb/src/scripts/execution/httpServerScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class HttpServerScripts extends BaseScripts {
const port = await checkAndKillPortProcess(project.env.PORT, project);
const suffix = project.packageJson.scripts?.['test/e2e-additional'] ? ' && YARN test/e2e-additional' : '';
const targets = argv.targets?.map(String);
const normalizedTargets = targets?.length ? targets : ['test/e2e/'];
const testCommand = this.testUnit(project, { ...argv, targets: normalizedTargets });
return buildShellCommand([
'YARN',
'wb',
Expand All @@ -42,16 +44,7 @@ class HttpServerScripts extends BaseScripts {
'--success',
'first',
`${startCommand} && exit 1`,
`wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port}
&& ${buildShellCommand([
'vitest',
'run',
...(targets && targets.length > 0 ? targets : ['test/e2e/']),
'--color',
'--passWithNoTests',
'--allowOnly',
...(argv.bail ? ['--bail=1'] : []),
])}${suffix}`,
`wait-on -t 600000 -i 2000 http-get://127.0.0.1:${port} && ${testCommand}${suffix}`,
]);
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/wb/test/scripts/execution/httpServerScripts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('HttpServerScripts.testE2E', () => {
env: { WB_ENV: 'test', PORT: '3000' },
packageJson: { scripts: {} },
hasPlaywrightConfig: false,
hasVitest: true,
hasPrisma: false,
buildCommand: 'echo "no build"',
findFile: vi.fn().mockImplementation(() => {
Expand Down Expand Up @@ -51,6 +52,7 @@ describe('HttpServerScripts.testE2E', () => {
env: { WB_ENV: 'test', PORT: '3000' },
packageJson: { scripts: {} },
hasPlaywrightConfig: false,
hasVitest: true,
hasPrisma: false,
buildCommand: 'echo "no build"',
findFile: vi.fn().mockImplementation(() => {
Expand All @@ -73,15 +75,16 @@ describe('HttpServerScripts.testE2E', () => {
'--success',
'first',
'YARN wb buildIfNeeded && node dist/index.js && exit 1',
`wait-on -t 600000 -i 2000 http-get://127.0.0.1:3000
&& ${buildShellCommand([
`wait-on -t 600000 -i 2000 http-get://127.0.0.1:3000 && ${buildShellCommand([
'YARN',
'vitest',
'run',
`test/e2e/quo'te.spec.ts`,
'test/e2e/space path.spec.ts',
'--color',
'--passWithNoTests',
'--allowOnly',
'--watch=false',
])}`,
])
);
Expand Down
Loading