Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support playwright as an alternative e2e test framework #2432

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
78 changes: 54 additions & 24 deletions .github/workflows/applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Prepare JHipster Svelte Image
runs-on: ubuntu-latest
concurrency:
group: apps-dev-${{ matrix.apps }}-${{ github.head_ref || github.sha }}
group: apps-dev-${{ matrix.apps }}-${{ matrix.test_framework }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
timeout-minutes: 5
steps:
Expand All @@ -31,12 +31,12 @@ jobs:
retention-days: 1
development-profile-builds:
needs: svelte-image
name: ${{ matrix.apps }}
name: ${{ matrix.apps }} (${{ matrix.test_framework }})
concurrency:
group: apps-dev-${{ matrix.apps }}-${{ github.head_ref || github.sha }}
group: apps-dev-${{ matrix.apps }}-${{ matrix.test_framework }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
runs-on: ${{ matrix.os }}
timeout-minutes: 15
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand All @@ -47,6 +47,7 @@ jobs:
]
os: [ubuntu-latest]
node_version: [20.x]
test_framework: ['cypress', 'playwright']
steps:
- uses: actions/checkout@v4
- name: Download latest chrome binary
Expand Down Expand Up @@ -79,6 +80,11 @@ jobs:
~/.cache/Cypress/13.5.x
~/.cache/Cypress/cy
key: ${{ runner.os }}-cypress-13.5.x
- name: Configure playwright cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-1.49.x
- name: Retrieve saved Svelte Docker Image
uses: actions/download-artifact@v4
with:
Expand All @@ -99,13 +105,13 @@ jobs:
run: |
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} .yo-rc.json
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA --no-insight --force --jest --swagger-ui
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA --no-insight --force --jest --swagger-ui --test-framework ${{ matrix.test_framework }}
- name: Generate application
if: contains(matrix.apps, '.jdl')
run: |
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} app.jdl
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force --test-framework ${{ matrix.test_framework }}
- name: Maven - Unit tests
if: contains(matrix.apps , 'maven')
run: |
Expand Down Expand Up @@ -134,25 +140,27 @@ jobs:
run: |
cd "$HOME/svelte-app"
docker run --rm -v $PWD:/app -v $HOME/.gradle:/home/jsvelte/.gradle --entrypoint ./gradlew jhipster/jhipster-svelte:$GITHUB_SHA bootJar --no-daemon
- name: Maven - Cypress tests
- name: Maven - E2E tests
if: contains(matrix.apps , 'maven')
run: |
cd "$HOME/svelte-app"
docker run -d --rm -v $PWD:/app -v $HOME/.m2:/home/jsvelte/.m2 -p8080:8080 --entrypoint ./mvnw jhipster/jhipster-svelte:$GITHUB_SHA -DskipTests -Dspring-boot.run.jvmArguments="-Dspring.docker.compose.enabled=false"
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
npm run e2e:ci
- name: Gradle Cypress tests
- name: Gradle - E2E tests
if: contains(matrix.apps, 'gradle')
run: |
cd "$HOME/svelte-app"
docker run --rm -v $PWD:/app -v $HOME/.gradle:/home/jsvelte/.gradle --entrypoint ./gradlew jhipster/jhipster-svelte:$GITHUB_SHA clean
docker run -d --rm -v $PWD:/app -v $HOME/.gradle:/home/jsvelte/.gradle -p8080:8080 --entrypoint ./gradlew jhipster/jhipster-svelte:$GITHUB_SHA -x test
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
npm run e2e:ci
development-profile-non-docker-builds:
name: ${{ matrix.apps }}
name: ${{ matrix.apps }} (${{ matrix.test_framework }})
concurrency:
group: apps-dev-${{ matrix.apps }}-${{ github.head_ref || github.sha }}
group: apps-dev-${{ matrix.apps }}-${{ matrix.test_framework }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
runs-on: ${{ matrix.os }}
timeout-minutes: 20
Expand All @@ -162,6 +170,7 @@ jobs:
apps: ['monolithic-session-gradle.json', 'monolithic-jwt-gradle.json']
os: [ubuntu-latest]
node_version: [20.x]
test_framework: ['cypress', 'playwright']
steps:
- uses: actions/checkout@v4
- name: Download latest chrome binary
Expand Down Expand Up @@ -198,6 +207,11 @@ jobs:
~/.cache/Cypress/13.5.x
~/.cache/Cypress/cy
key: ${{ runner.os }}-cypress-13.5.x
- name: Configure playwright cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-1.49.x
- name: Prepare environment
run: |
mkdir -p "$HOME/svelte-app"
Expand All @@ -213,7 +227,7 @@ jobs:
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} .yo-rc.json
npm link "generator-jhipster-svelte"
jsvelte --no-insight --force --jest --swagger-ui
jsvelte --no-insight --force --jest --swagger-ui --test-framework ${{ matrix.test_framework }}
- name: Maven - Unit tests
if: contains(matrix.apps , 'maven')
run: |
Expand Down Expand Up @@ -242,30 +256,32 @@ jobs:
run: |
cd "$HOME/svelte-app"
./gradlew bootJar --no-daemon
- name: Maven - Cypress tests
- name: Maven - E2E tests
if: contains(matrix.apps , 'maven')
run: |
cd "$HOME/svelte-app"
./mvnw -svelte:$GITHUB_SHA -DskipTests &
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
npm run e2e:ci
- name: Gradle Cypress tests
- name: Gradle - E2E tests
if: contains(matrix.apps, 'gradle')
run: |
cd "$HOME/svelte-app"
./gradlew -x test &
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
npm run e2e:ci

production-profile-builds:
needs: svelte-image
name: ${{ matrix.apps }}
name: ${{ matrix.apps }} (${{ matrix.test_framework }})
concurrency:
group: apps-prod-${{ matrix.apps }}-${{ github.head_ref || github.sha }}
group: apps-prod-${{ matrix.apps }}-${{ matrix.test_framework }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
if: github.event.action != 'closed'
runs-on: ${{ matrix.os }}
timeout-minutes: 15
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand All @@ -278,6 +294,7 @@ jobs:
]
os: [ubuntu-latest]
node_version: [20.x]
test_framework: ['cypress', 'playwright']
steps:
- uses: actions/checkout@v4
- name: Download latest chrome binary
Expand Down Expand Up @@ -314,6 +331,11 @@ jobs:
~/.cache/Cypress/13.5.x
~/.cache/Cypress/cy
key: ${{ runner.os }}-cypress-13.5.x
- name: Configure playwright cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-1.49.x
- name: Retrieve saved Svelte Docker Image
uses: actions/download-artifact@v4
with:
Expand All @@ -334,13 +356,13 @@ jobs:
run: |
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} .yo-rc.json
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA --no-insight --force
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA --no-insight --force --test-framework ${{ matrix.test_framework }}
- name: Generate application
if: contains(matrix.apps, '.jdl')
run: |
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} app.jdl
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force --test-framework ${{ matrix.test_framework }}
- name: Maven - Unit tests
if: contains(matrix.apps , 'maven')
run: |
Expand Down Expand Up @@ -388,18 +410,19 @@ jobs:
sudo echo "127.0.0.1 keycloak" | sudo tee -a /etc/hosts
docker compose -f src/main/docker/keycloak.yml up -d
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9080/realms/master)" != "200" ]]; do sleep 5; done' || false
- name: Run Cypress tests
- name: Run E2E tests
run: |
cd "$HOME/svelte-app"
sudo echo "127.0.0.1 keycloak" | sudo tee -a /etc/hosts
docker compose -f src/main/docker/app.yml up -d
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
npm run e2e:ci
microservices-production-profile-builds:
needs: svelte-image
name: ${{ matrix.apps }}
name: ${{ matrix.apps }} (${{ matrix.test_framework }})
concurrency:
group: ms-apps-prod-${{ matrix.apps }}-${{ github.head_ref || github.sha }}
group: ms-apps-prod-${{ matrix.apps }}-${{ matrix.test_framework }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
if: github.event.action != 'closed'
runs-on: ${{ matrix.os }}
Expand All @@ -410,6 +433,7 @@ jobs:
apps: ['microservices-oidc-maven-prod.jdl']
os: [ubuntu-latest]
node_version: [20.x]
test_framework: ['cypress', 'playwright']
steps:
- uses: actions/checkout@v4
- name: Download latest chrome binary
Expand Down Expand Up @@ -446,6 +470,11 @@ jobs:
~/.cache/Cypress/13.5.x
~/.cache/Cypress/cy
key: ${{ runner.os }}-cypress-13.5.x
- name: Configure playwright cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-1.49.x
- name: Retrieve saved Svelte Docker Image
uses: actions/download-artifact@v4
with:
Expand All @@ -466,7 +495,7 @@ jobs:
run: |
cd "$HOME/svelte-ms"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} app.jdl
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --skip-checks --force
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --skip-checks --force --test-framework ${{ matrix.test_framework }}
- name: Maven - Unit tests - Gateway
if: contains(matrix.apps , 'maven')
run: |
Expand Down Expand Up @@ -546,13 +575,14 @@ jobs:
cd "$HOME/svelte-ms/docker-compose"
docker compose up -d keycloak
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9080/realms/master)" != "200" ]]; do sleep 5; done' || false
- name: Run Cypress tests
- name: Run E2E tests
run: |
sudo echo "127.0.0.1 keycloak" | sudo tee -a /etc/hosts
cd "$HOME/svelte-ms/docker-compose"
docker compose up -d
timeout 180 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/authenticate)" != "200" ]]; do sleep 5; done' || false
cd "$HOME/svelte-ms/gateway"
${{ matrix.test_framework == 'playwright' && 'npx playwright install --with-deps' || '' }}
# npm run e2e:ci
lighthouse-job:
needs: svelte-image
Expand Down Expand Up @@ -617,7 +647,7 @@ jobs:
run: |
cd "$HOME/svelte-app"
cp $TEST_SCRIPTS_PATH/${{ matrix.apps }} app.jdl
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force
docker run --rm -v $PWD:/app -v $HOME/.cache:/home/jsvelte/.cache jhipster/jhipster-svelte:$GITHUB_SHA import-jdl app.jdl --no-insight --force --test-framework cypress
rm -rf node_modules/generator-jhipster-svelte
- name: Build application docker image
run: |
Expand Down
14 changes: 9 additions & 5 deletions generators/client/command.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const command = {
configs: {},
import { asCommand } from 'generator-jhipster';

export default asCommand({
options: {
jest: {
description: 'Jest JavaScript unit testing framework',
Expand All @@ -11,7 +12,10 @@ const command = {
type: Boolean,
scope: 'blueprint',
},
testFramework: {
description: 'E2E testing framework to use',
type: String,
scope: 'blueprint',
},
},
};

export default command;
});
38 changes: 28 additions & 10 deletions generators/client/entity-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,53 @@ export default {
{
templates: [
{
file: 'cypress/integration/entities/entity/entity-delete.spec.js',
file: generator => `${generator.testFramework}/integration/entities/entity/entity-delete.spec.js`,
renameTo: generator =>
`cypress/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-delete.spec.js`,
`${generator.testFramework}/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-delete.spec.js`,
},
{
file: 'cypress/integration/entities/entity/entity-list.spec.js',
file: generator => `${generator.testFramework}/integration/entities/entity/entity-list.spec.js`,
renameTo: generator =>
`cypress/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-list.spec.js`,
`${generator.testFramework}/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-list.spec.js`,
},
{
file: 'cypress/integration/entities/entity/entity-view.spec.js',
file: generator => `${generator.testFramework}/integration/entities/entity/entity-view.spec.js`,
renameTo: generator =>
`cypress/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-view.spec.js`,
`${generator.testFramework}/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-view.spec.js`,
},
{
file: 'cypress/integration/entities/entity/entity-create.spec.js',
file: generator => `${generator.testFramework}/integration/entities/entity/entity-create.spec.js`,
renameTo: generator =>
`cypress/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-create.spec.js`,
`${generator.testFramework}/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-create.spec.js`,
},
{
file: 'cypress/integration/entities/entity/entity-update.spec.js',
file: generator => `${generator.testFramework}/integration/entities/entity/entity-update.spec.js`,
renameTo: generator =>
`cypress/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-update.spec.js`,
`${generator.testFramework}/integration/entities/${generator.entityFolderName}/${generator.entityFileName}-update.spec.js`,
},
],
},
],
entityCypressUtils: [
{
condition: generator => generator.testFramework === 'cypress',
templates: [
{
file: 'cypress/support/entities/entity-util.js',
renameTo: generator => `cypress/support/entities/${generator.entityFileName}-util.js`,
},
],
},
],
entityPlaywrightUtils: [
{
condition: generator => generator.testFramework === 'playwright',
templates: [
{
file: 'playwright/utils/entities/entity-util.js',
renameTo: generator => `playwright/utils/entities/${generator.entityFileName}-utils.js`,
},
],
},
],
};
Loading