Refactor tests and add codecov

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-01-16 14:04:07 +01:00
parent 6c0938e214
commit 3bca612ac1
10 changed files with 15 additions and 38 deletions

View File

@ -44,6 +44,7 @@ install_mongo: &install_mongo
before_script:
- yarn build
- yarn global add -g wait-on
- yarn global add codecov
jobs:
include:
@ -56,8 +57,8 @@ jobs:
name: 'Lint / Unit Tests '
script:
- yarn run -s lint
- yarn run -s test:unit
- yarn run -s test:front
- yarn run -s test:unit && codecov -F unit
- yarn run -s test:front && codecov -F front
- <<: *e2e_tests
name: 'E2E Postgresql'

View File

@ -1,6 +1,5 @@
module.exports = {
name: 'setup',
displayName: 'Setup',
name: 'Api integration tests',
testMatch: ['**/?(*.)+(spec|test).e2e.js'],
testEnvironment: 'node',
coveragePathIgnorePatterns: [

View File

@ -1,13 +1,5 @@
module.exports = {
name: 'setup',
displayName: 'Setup',
testMatch: ['**/test/?(*.)+(spec|test).js'],
testPathIgnorePatterns: ['<rootDir>/packages/'],
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
'<rootDir>/out-tsc/',
'<rootDir>/test/',
],
name: 'Unit test',
testMatch: ['**/packages/**/__tests__/?(*.)+(spec|test).js'],
transform: {},
};

View File

@ -49,7 +49,7 @@
"test:front:watch": "cross-env NODE_ENV=test jest --config ./jest.config.front.js --watchAll",
"test:front:update": "cross-env NODE_ENV=test jest --config ./jest.config.front.js --u",
"test:snyk": "snyk test",
"test:unit": "lerna exec -- npm run test -s",
"test:unit": "jest --verbose",
"test:e2e": "FORCE_COLOR=true jest --config jest.config.e2e.js --runInBand --verbose --forceExit --detectOpenHandles",
"test:generate-app": "node test/createTestApp.js",
"test:start-app": "node test/startTestApp.js"

View File

@ -8,9 +8,6 @@
"description": "content-manager.plugin.description",
"required": true
},
"scripts": {
"test": "jest services"
},
"dependencies": {
"classnames": "^2.2.6",
"codemirror": "^5.46.0",

View File

@ -1,3 +0,0 @@
module.exports = {
testMatch: ['**/__tests__/?(*.)+(spec|test).js'],
};

View File

@ -7,9 +7,6 @@
"icon": "paint-brush",
"description": "content-type-builder.plugin.description"
},
"scripts": {
"test": "jest --verbose --config=jest.config.unit.js"
},
"dependencies": {
"@sindresorhus/slugify": "^0.9.1",
"classnames": "^2.2.6",

View File

@ -14,9 +14,6 @@
"lib": "./lib"
},
"main": "./lib",
"scripts": {
"test": "jest"
},
"dependencies": {
"date-fns": "^2.8.1",
"knex": "^0.16.5",

View File

@ -1,6 +1,7 @@
const fs = require('../fs');
const fse = require('fs-extra');
jest.mock('fs-extra');
const fsExtra = require('fs-extra');
describe('Strapi fs utils', () => {
const strapi = {
@ -22,8 +23,8 @@ describe('Strapi fs utils', () => {
await strapiFS.writeAppFile('test', content);
expect(fsExtra.ensureFile).toHaveBeenCalledWith('/tmp/test');
expect(fsExtra.writeFile).toHaveBeenCalledWith('/tmp/test', content);
expect(fse.ensureFile).toHaveBeenCalledWith('/tmp/test');
expect(fse.writeFile).toHaveBeenCalledWith('/tmp/test', content);
});
test('Normalize the path to avoid relative access to folders in parent directories', async () => {
@ -33,8 +34,8 @@ describe('Strapi fs utils', () => {
await strapiFS.writeAppFile('../../test', content);
expect(fsExtra.ensureFile).toHaveBeenCalledWith('/tmp/test');
expect(fsExtra.writeFile).toHaveBeenCalledWith('/tmp/test', content);
expect(fse.ensureFile).toHaveBeenCalledWith('/tmp/test');
expect(fse.writeFile).toHaveBeenCalledWith('/tmp/test', content);
});
test('Works with array path', async () => {
@ -44,11 +45,8 @@ describe('Strapi fs utils', () => {
await strapiFS.writeAppFile(['test', 'sub', 'path'], content);
expect(fsExtra.ensureFile).toHaveBeenCalledWith('/tmp/test/sub/path');
expect(fsExtra.writeFile).toHaveBeenCalledWith(
'/tmp/test/sub/path',
content
);
expect(fse.ensureFile).toHaveBeenCalledWith('/tmp/test/sub/path');
expect(fse.writeFile).toHaveBeenCalledWith('/tmp/test/sub/path', content);
});
});

View File

@ -61,7 +61,6 @@
"strapi-utils": "3.0.0-beta.18.4"
},
"scripts": {
"test": "jest --verbose",
"postinstall": "node lib/utils/success.js"
},
"author": {