diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a61d034c..975d3bf86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - run: yarn - - run: yarn test + - run: yarn lint + - run: yarn test --coverage - run: yarn build - name: Upload build uses: actions/upload-artifact@v3 diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 000000000..307c6d9fc --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,39 @@ +name: Playwright Tests +on: + pull_request: + branches: [main, master] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout Pearl + uses: actions/checkout@v4 + with: + path: Pearl-Jam + - name: Checkout Queen + uses: actions/checkout@v4 + with: + repository: inseefr/drama-queen + path: Drama-Queen + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: | + npm install -g yarn + yarn --cwd Pearl-Jam + yarn --cwd Drama-Queen + - name: Install Playwright Browsers + working-directory: ./Pearl-Jam + run: npx playwright install --with-deps + - name: Run Playwright tests + working-directory: ./Pearl-Jam + run: | + npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: Pearl-Jam/playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index bd98e77ad..2a6c1de7e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,8 @@ dist-ssr *.njsproj *.sln *.sw? +coverage +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/README.md b/README.md index c181371ff..56665eab2 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,26 @@ # Pearl Jam Case management web application for Computer-Assisted Personal Interviewing (CAPI) + +## Running Unit Tests + +Unit Tests use the **Vitest** framework. You can run these tests with the following command: + +```shell +yarn test +yarn test --coverage +``` + +## Running Playwright Tests + +We can also run end-to-end test thank to **Playwright**. + +``` +npx playwright test +npx playwright test --ui +``` + +Before executing the test, we will : + +- build the project (in order to be sure that the test are running on the production-ready application) +- launch a static server (thanks to **npx serve**) diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..cebfe54f2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,36 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import pluginReact from 'eslint-plugin-react'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; + +export default [ + { files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + pluginReact.configs.flat['jsx-runtime'], + eslintPluginPrettierRecommended, + { + settings: { react: { version: '18.3' } }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + 'no-undef': 'off', + '@typescript-eslint/no-unused-vars': 'off', + 'no-fallthrough': 'off', + }, + languageOptions: { + globals: { + it: 'readonly', + describe: 'readonly', + expect: 'readonly', + vi: 'readonly', + beforeEach: 'readonly', + global: 'readonly', + beforeAll: 'readonly', + afterAll: 'readonly', + test: 'readonly', + }, + }, + }, +]; diff --git a/index.html b/index.html index a785ad381..7c44fa953 100644 --- a/index.html +++ b/index.html @@ -3,10 +3,7 @@ - +