diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..7e842dbf7f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,16 @@ +name: End-to-end tests + +on: push + +jobs: + cypress-run: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + # Install npm dependencies, cache them correctly + # and run all Cypress tests + - name: Cypress run + uses: cypress-io/github-action@v6 + with: + start: yarn dev diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d014e7803e..78657dad9a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,3 +21,9 @@ We use the [yarn](https://yarnpkg.com/getting-started/install) for package manag ```sh yarn build ``` + +## Tests + +```sh +yarn test +``` diff --git a/README.md b/README.md index dd459fcf74..970353d7b0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Works with an Open Prices server, see https://github.com/openfoodfacts/open-pric ## Contribute -See [CONTRIBUTING.md](https://github.com/openfoodfacts/open-prices-frontend/blob/main/CONTRIBUTING.md) +See [CONTRIBUTING.md](https://github.com/openfoodfacts/open-prices-frontend/blob/master/CONTRIBUTING.md)

Weekly meetings

* see https://github.com/openfoodfacts/open-prices#weekly-meetings diff --git a/cypress.config.js b/cypress.config.js new file mode 100644 index 0000000000..9938981923 --- /dev/null +++ b/cypress.config.js @@ -0,0 +1,16 @@ +const { defineConfig } = require("cypress"); + +module.exports = defineConfig({ + e2e: { + specPattern: '**/*.cy.js', + fixturesFolder: 'tests/fixtures', + screenshotsFolder: 'tests/screenshots', + videosFolder: 'tests/videos', + downloadsFolder: 'tests/downloads', + supportFile: 'tests/support/e2e.js', + setupNodeEvents(on, config) { + // implement node event listeners here + }, + baseUrl: 'http://localhost:5173', + }, +}); diff --git a/package.json b/package.json index 68b8cbf742..ffd9d97a95 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "build": "vite build", "build-staging": "vite build --base=/app/ --mode preprod", "build-prod": "vite build --base=/app/ --mode prod", - "preview": "vite preview" + "preview": "vite preview", + "cy:open": "cypress open", + "cy:run": "cypress run", + "test": "start-server-and-test dev http://localhost:5173 cy:run" }, "dependencies": { "@intlify/unplugin-vue-i18n": "^2.0.0", @@ -33,7 +36,9 @@ "@vue/compiler-sfc": "^3.3.9", "autoprefixer": "^10.4.16", "cross-env": "^7.0.3", + "cypress": "^13.8.1", "postcss": "^8.4.31", + "start-server-and-test": "^2.0.3", "vite": "^4.5.0" }, "resolutions": { diff --git a/src/components/PriceCard.vue b/src/components/PriceCard.vue index 87f89f5ca3..cc3e1edcff 100644 --- a/src/components/PriceCard.vue +++ b/src/components/PriceCard.vue @@ -1,5 +1,5 @@ diff --git a/src/components/ProductCard.vue b/src/components/ProductCard.vue index c3caae8a70..a5477dd5b3 100644 --- a/src/components/ProductCard.vue +++ b/src/components/ProductCard.vue @@ -1,5 +1,5 @@