mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
chore: pr amends
Update docs/docs/guides/e2e/02-data-transfer.md Update docs/docs/guides/e2e/01-app-template.md Update docs/docs/guides/e2e/00-setup.md Update docs/docs/guides/e2e/00-setup.md Update docs/docs/guides/e2e/02-data-transfer.md Update test/scripts/run-e2e-tests.js Co-Authored-By: Ben Irvin <ben@innerdvations.com>
This commit is contained in:
parent
b79ccf8628
commit
f45146aa97
@ -13,13 +13,20 @@ This document explains at a high level how we create our app instance, run the e
|
||||
|
||||
## Get Started
|
||||
|
||||
To run the e2e tests, you must first install the playwright browsers.
|
||||
|
||||
```shell
|
||||
npx playwright install
|
||||
```
|
||||
Because we require a "fresh" instance to assert our e2e tests against this is included in the testing script so all you need to run is:
|
||||
|
||||
```shell
|
||||
yarn test:e2e
|
||||
```
|
||||
|
||||
This will spawn a Strapi instance in `test-apps/playwright` where the `playwright.config` will start the instance and run tests against. It will not install the dependencies because `test-apps` are considered part of the monorepo therefore using the most recent version of strapi (published or development) meaning our most recent code changes can be tested against.
|
||||
This will spawn by default a Strapi instance per testing domain (e.g. content-manager) in `test-apps` where the an individual `playwright.config` will start the instance and run tests against. It will automatically link the dependencies from the instance to the monorepo because `test-apps` are not considered part of the monorepo but we want to be using the most recent version of strapi (published or development) therefore meaning our most recent code changes can be tested against.
|
||||
|
||||
If you need to clean the test-apps folder because they are not working as expected, you can run `yarn test:e2e clean` which will clean said directory.
|
||||
|
||||
## Strapi Templates
|
||||
|
||||
@ -35,6 +42,6 @@ For more information check out their [docs](https://playwright.dev/docs/intro).
|
||||
|
||||
## What makes a good end to end test?
|
||||
|
||||
This is the million dollar question. E2E tests typically test complete user flows that touch numerous points of the application it's testing, we're not interested in asserting API responses, we're writing from the perspective of the user so consider writing them with your story hat on. E.g. "As a user I want to create a new entity and publish that entity".
|
||||
This is the million dollar question. E2E tests typically test complete user flows that touch numerous points of the application it's testing, we're not interested in what happens during a process, only the user perspective and end results. Consider writing them with your story hat on. E.g. "As a user I want to create a new entity, publish that entity, and then be able to retrieve its data from the content API".
|
||||
|
||||
Our E2E test suite should _at minimum_ cover the core business flows of the product and this is lead by the QA defined set for this. Consult with your QA if you're not sure.
|
||||
@ -9,6 +9,8 @@ tags:
|
||||
|
||||
## Overview
|
||||
|
||||
An app template has been created in `e2e/app-template` which provide some customizations and utilities to allow the tests to run. Note that if any changes are made to the app template, you will need to run `yarn test:e2e:clean` to update the test apps with the new template.
|
||||
|
||||
Here you can read about what content schemas the test instance has & the API customisations we've built (incl. why we built them).
|
||||
|
||||
## Content Schemas
|
||||
@ -26,13 +26,13 @@ The full documentation of the feature can be seen [here](https://docs.strapi.io/
|
||||
Because we're using an Strapi template for the test instance, it makes the most sense to add/edit the dataset in said templated instance. Begin by creating the instance:
|
||||
|
||||
```shell
|
||||
yarn test:e2e:setup
|
||||
yarn test:e2e
|
||||
```
|
||||
|
||||
Then, you should be able to navigate to the app – `cd ./test-apps/playwright`, the current content schemas should already be defined in there so you will be able to instantly import the current data packet to bring to life the test instance (instead of it being fresh):
|
||||
Then, you should be able to navigate to the app – `cd ./test-apps/test-app-XX`, the current content schemas should already be defined in there so you will be able to instantly import the current data packet to bring to life the test instance (instead of it being fresh):
|
||||
|
||||
```shell
|
||||
yarn strapi import --file ../../e2e/data/backup.tar
|
||||
yarn strapi import --file ../../../e2e/data/backup.tar
|
||||
```
|
||||
|
||||
Once that's completed, you should be able to run your Strapi instance as usual:
|
||||
5
docs/docs/guides/e2e/_category_.json
Normal file
5
docs/docs/guides/e2e/_category_.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"label": "E2E Testing",
|
||||
"collapsible": true,
|
||||
"collapsed": false
|
||||
}
|
||||
@ -10,9 +10,9 @@
|
||||
"strapi": "strapi"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/strapi": "4.5.5",
|
||||
"@strapi/plugin-users-permissions": "4.5.5",
|
||||
"@strapi/plugin-i18n": "4.5.5",
|
||||
"@strapi/strapi": "latest",
|
||||
"@strapi/plugin-users-permissions": "latest",
|
||||
"@strapi/plugin-i18n": "latest",
|
||||
"better-sqlite3": "7.4.6"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@ -48,7 +48,6 @@ const generateTestApp = async ({ appPath, database, template }) => {
|
||||
'@strapi/plugin-graphql',
|
||||
'@strapi/plugin-documentation',
|
||||
'@strapi/plugin-i18n',
|
||||
'@strapi/admin',
|
||||
],
|
||||
additionalsDependencies: {},
|
||||
template: template ? path.resolve(template) : template,
|
||||
|
||||
@ -102,7 +102,7 @@ yargs
|
||||
database: {
|
||||
client: 'sqlite',
|
||||
connection: {
|
||||
filename: './tmp/data.db',
|
||||
filename: './.tmp/data.db',
|
||||
},
|
||||
useNullAsDefault: true,
|
||||
},
|
||||
@ -117,7 +117,6 @@ yargs
|
||||
const pathToEnv = path.join(appPath, '.env');
|
||||
const envFile = (await fs.readFile(pathToEnv)).toString();
|
||||
const envWithoutPort = envFile.replace('PORT=1337', '');
|
||||
const envWitoutHost = envWithoutPort.replace('HOST=0.0.0.0', '');
|
||||
await fs.writeFile(pathToEnv, envWithoutPort);
|
||||
/**
|
||||
* Always build! Just incase.
|
||||
@ -131,7 +130,7 @@ yargs
|
||||
);
|
||||
|
||||
console.log(
|
||||
`${chalk.green('Successfully')} setup test apps for the follwing domains: ${chalk.bold(
|
||||
`${chalk.green('Successfully')} setup test apps for the following domains: ${chalk.bold(
|
||||
domains.join(', ')
|
||||
)}`
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user