提交 d1470156 编写于 作者: A Alexandre Bodin

Updates after review

- Clean comments
- Ignore all tmp paths with a Regexp
上级 6b417aa1
......@@ -50,19 +50,16 @@ jobs:
before_install:
- mysql -e 'CREATE DATABASE strapi_test;'
env:
# mysql
- DB_STRING='--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=travis --dbpassword='
- <<: *e2e_tests
name: 'E2E Sqlite'
env:
# sqlite
- DB_STRING='--dbclient=sqlite --dbfile=./tmp/data.db'
- <<: *e2e_tests
name: 'E2E MongoDB'
env:
# mongo
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='
- name: 'Cypress tests'
......
......@@ -144,6 +144,75 @@ The administration panel is available at http://localhost:4000/admin
---
## Running the tests
You can run three different kind of tests:
- Unit tests
- End to end tests
- Cypress (integration) tests
### Unit tests
This will run the npm `test` script in every packages
```bash
$ npm run test:unit
```
### End to end
This will create a test app, start it and run the end to end tests against it.
> ️️️️️️️You can change `test/e2e.js` to configure the database you want to use:
```js
// test/e2e.js
//...
const main = async () => {
// you can switch databases.mongo for databases.mysql or any other
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.mongo;
//...
}
```
Then run
```bash
$ node test/e2e.js
```
### Cypress
This will create a test app, start it and finally run the cypress tests against it.
> You can change `test/createTestApp.js` to configure the database you want to use.
```js
// test/createTestApp.js
//...
const main = async () => {
// you can switch databases.mongo for databases.mysql or any other
const database = process.argv.length > 2 ? process.argv.slice(2).join(' ') : databases.postgres;
//...
}
```
> ⚠️ To run the cypress test you must have run `npm run setup:build` to setup the repository
Then run
```bash
# generate the test app
$ node test/createTestApp.js
# run the testApp in the background (️️️⚠️ be carefull to kill the process after the tests have run)
$ node test/startTestApp.js &
# run cypress
$ node test/cypress
```
---
## Reporting an issue
Before reporting an issue you need to make sure:
......
......@@ -3,7 +3,6 @@ module.exports = {
displayName: 'Setup',
testMatch: ['**/test/?(*.)+(spec|test).e2e.js'],
testEnvironment: 'node',
// globalSetup: '<rootDir>/test/globalSetup.js',
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
......
......@@ -25,7 +25,8 @@
"request-promise-native": "^1.0.7",
"shelljs": "^0.7.7",
"snyk": "^1.99.0",
"strapi-lint": "file:packages/strapi-lint"
"strapi-lint": "file:packages/strapi-lint",
"wait-on": "^3.2.0"
},
"scripts": {
"clean": "npm run removesymlinkdependencies && npx rimraf package-lock.json && npx rimraf packages/*/package-lock.json",
......
......@@ -659,7 +659,7 @@ describe('Create Strapi API End to End', () => {
});
const { body: referenceToGet } = await rq({
url: `/references/${referenceToCreate.id || referenceToCreate._id}`,
url: `/references/${referenceToCreate.id}`,
method: 'GET',
});
......
......@@ -53,4 +53,4 @@
"npm": ">= 6.0.0"
},
"license": "MIT"
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@ const watchFileChanges = ({ appPath, strapi }) => {
ignoreInitial: true,
ignored: [
/(^|[/\\])\../,
'**/tmp',
/tmp/,
'**/admin',
'**/components',
'**/documentation',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册