mirror of
https://github.com/strapi/strapi.git
synced 2025-10-08 23:04:02 +00:00
better handle env variables in e2e tests
This commit is contained in:
parent
e58b7266e1
commit
83d321a981
@ -79,6 +79,7 @@
|
|||||||
"chalk": "4.1.1",
|
"chalk": "4.1.1",
|
||||||
"chokidar": "3.5.1",
|
"chokidar": "3.5.1",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
|
"dotenv": "14.2.0",
|
||||||
"enzyme": "3.9.0",
|
"enzyme": "3.9.0",
|
||||||
"enzyme-adapter-react-16": "1.15.6",
|
"enzyme-adapter-react-16": "1.15.6",
|
||||||
"eslint": "7.25.0",
|
"eslint": "7.25.0",
|
||||||
|
@ -8,7 +8,6 @@ const appName = 'testApp';
|
|||||||
process.env.ENV_PATH = path.resolve(__dirname, '..', appName, '.env');
|
process.env.ENV_PATH = path.resolve(__dirname, '..', appName, '.env');
|
||||||
|
|
||||||
const { cleanTestApp, generateTestApp } = require('./helpers/test-app-generator');
|
const { cleanTestApp, generateTestApp } = require('./helpers/test-app-generator');
|
||||||
const { createStrapiInstance } = require('./helpers/strapi');
|
|
||||||
|
|
||||||
const databases = {
|
const databases = {
|
||||||
postgres: {
|
postgres: {
|
||||||
@ -41,10 +40,6 @@ const databases = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const runAllTests = async args => {
|
const runAllTests = async args => {
|
||||||
// start and destroy instance once so it correctly generate env variables without concurrent instances
|
|
||||||
await createStrapiInstance();
|
|
||||||
await strapi.destroy();
|
|
||||||
|
|
||||||
return execa('yarn', ['test:e2e', ...args], {
|
return execa('yarn', ['test:e2e', ...args], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
cwd: path.resolve(__dirname, '..'),
|
cwd: path.resolve(__dirname, '..'),
|
||||||
@ -60,8 +55,7 @@ const main = async (database, args) => {
|
|||||||
await cleanTestApp(appName);
|
await cleanTestApp(appName);
|
||||||
await generateTestApp({ appName, database });
|
await generateTestApp({ appName, database });
|
||||||
|
|
||||||
await runAllTests(args).catch(e => {
|
await runAllTests(args).catch(() => {
|
||||||
console.error(e);
|
|
||||||
process.stdout.write('Tests failed\n', () => {
|
process.stdout.write('Tests failed\n', () => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const dotenv = require('dotenv');
|
||||||
const strapi = require('../../packages/core/strapi/lib');
|
const strapi = require('../../packages/core/strapi/lib');
|
||||||
const { createUtils } = require('./utils');
|
const { createUtils } = require('./utils');
|
||||||
|
|
||||||
@ -21,6 +22,8 @@ const createStrapiInstance = async ({
|
|||||||
logLevel = 'fatal',
|
logLevel = 'fatal',
|
||||||
bypassAuth = true,
|
bypassAuth = true,
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
|
// read .env file as it could have been updated
|
||||||
|
dotenv.config({ path: process.env.ENV_PATH });
|
||||||
const options = { dir: TEST_APP_URL };
|
const options = { dir: TEST_APP_URL };
|
||||||
const instance = strapi(options);
|
const instance = strapi(options);
|
||||||
|
|
||||||
|
@ -9639,6 +9639,11 @@ dotenv@10.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
|
||||||
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
|
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
|
||||||
|
|
||||||
|
dotenv@14.2.0:
|
||||||
|
version "14.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-14.2.0.tgz#7e77fd5dd6cff5942c4496e1acf2d0f37a9e67aa"
|
||||||
|
integrity sha512-05POuPJyPpO6jqzTNweQFfAyMSD4qa4lvsMOWyTRTdpHKy6nnnN+IYWaXF+lHivhBH/ufDKlR4IWCAN3oPnHuw==
|
||||||
|
|
||||||
dotenv@8.5.1:
|
dotenv@8.5.1:
|
||||||
version "8.5.1"
|
version "8.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.5.1.tgz#e3a4c7862daba51b92bce0da5c349f11faa28663"
|
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.5.1.tgz#e3a4c7862daba51b92bce0da5c349f11faa28663"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user