Skip to content

Commit

Permalink
refactor playwright tests to use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Sep 18, 2024
1 parent 92f181d commit ee7e2eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/example-app-router-playground/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const withMdx = mdxPlugin();

export default withMdx(
withNextIntl({
trailingSlash: process.env.TRAILING_SLASH === 'true',
basePath: process.env.BASE_PATH === 'true' ? '/base/path' : undefined,
trailingSlash: process.env.USE_CASE === 'trailing-slash',
basePath: process.env.USE_CASE === 'base-path' ? '/base/path' : undefined,
experimental: {
staleTimes: {
// Next.js 14.2 broke `locale-prefix-never.spec.ts`.
Expand Down
7 changes: 2 additions & 5 deletions examples/example-app-router-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
"scripts": {
"dev": "next dev",
"lint": "eslint src && tsc",
"test": "pnpm run test:playwright:main && pnpm run test:playwright:locale-prefix-never && pnpm run test:playwright:trailing-slash && pnpm run test:jest && pnpm run test:playwright:base-path",
"test:playwright:main": "TEST_MATCH=main.spec.ts playwright test",
"test:playwright:locale-prefix-never": "NEXT_PUBLIC_LOCALE_PREFIX=never pnpm build && TEST_MATCH=locale-prefix-never.spec.ts playwright test",
"test:playwright:trailing-slash": "TRAILING_SLASH=true pnpm build && TEST_MATCH=trailing-slash.spec.ts playwright test",
"test:playwright:base-path": "BASE_PATH=true pnpm build && BASE_PATH=true TEST_MATCH=base-path.spec.ts playwright test",
"test": "pnpm test:jest && node test.mjs",
"test:playwright": "node runPlaywright.mjs",
"test:jest": "jest",
"build": "next build",
"start": "next start",
Expand Down
11 changes: 11 additions & 0 deletions examples/example-app-router-playground/runPlaywright.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {execSync} from 'child_process';

const useCases = ['main', 'locale-prefix-never', 'trailing-slash', 'base-path'];

for (const useCase of useCases) {
// eslint-disable-next-line no-console
console.log(`Running tests for use case: ${useCase}`);

const command = `USE_CASE=${useCase} pnpm build && USE_CASE=${useCase} TEST_MATCH=${useCase}.spec.ts playwright test`;
execSync(command, {stdio: 'inherit'});
}
2 changes: 1 addition & 1 deletion examples/example-app-router-playground/src/i18n/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const routing = defineRouting({
locales: ['en', 'de', 'es', 'ja'],
defaultLocale: 'en',
localePrefix:
process.env.NEXT_PUBLIC_LOCALE_PREFIX === 'never'
process.env.USE_CASE === 'locale-prefix-never'
? 'never'
: {
mode: 'as-needed',
Expand Down

0 comments on commit ee7e2eb

Please sign in to comment.