Run Jest in the monorepo packages

This commit is contained in:
Aurelsicoko 2018-06-12 17:41:28 +02:00
parent eef86d1bd6
commit c2d0e81f22
7 changed files with 61 additions and 18 deletions

13
jest.config.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
name: 'setup',
displayName: 'Setup',
testPathIgnorePatterns: [
'<rootDir>/packages/',
],
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
'<rootDir>/out-tsc/',
'<rootDir>/test/'
]
};

View File

@ -0,0 +1,10 @@
module.exports = {
name: 'content-manager',
displayName: 'Content Manager',
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
'<rootDir>/out-tsc/',
'<rootDir>/test/'
]
};

View File

@ -0,0 +1,8 @@
describe('Content-Manager', () => {
test(
'True',
async () => {
expect(true).toBeTruthy();
}
);
});

View File

@ -36,7 +36,7 @@ module.exports = function() {
}),
new Promise((resolve, reject) => {
// Load configurations.
glob('{./plugins/*/!(config|node_modules)/*.*(js|json),./plugins/*/package.json}', {
glob('{./plugins/*/!(config|node_modules|test)/*.*(js|json),./plugins/*/package.json}', {
cwd: this.config.appPath
}, (err, files) => {
if (err) {

View File

@ -51,6 +51,7 @@ const main = async () => {
const start = () => {
return new Promise((resolve) => {
try {
appStart = exec(
`node ${strapiBin} start ${appName}`,
);
@ -62,18 +63,29 @@ const main = async () => {
return resolve();
}
});
} catch (e) {
console.error(e);
}
});
};
const test = () => {
console.log('Launch test suits');
return new Promise(async (resolve) => {
const options = {
projects: [process.cwd()],
silent: false
};
// Run setup tests to generate the app.
await jest({
passWithNoTests: true
}, [process.cwd()]);
await jest(options, options.projects);
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'))
.filter(file => file.indexOf('strapi') !== -1);
// Run tests in every packages.
for (let i in packages) {
await jest({
passWithNoTests: true
}, [`${process.cwd()}/packages/${packages[i]}`]);
}
resolve();
});