config: streamline running core tests

by default running `npm run test:core` will only run unit tests.
E2E tests require setting up credentials in the .env file.
Until we figure out a way to streamline this whole process,
this is how the tests will be run.
This commit is contained in:
Abdullah Atta
2022-08-31 20:03:58 +05:00
parent 749d749879
commit 8fa4e2184f
7 changed files with 87 additions and 12 deletions

View File

@@ -1,4 +0,0 @@
{
"presets": ["@babel/preset-env"],
"plugins": [["@babel/transform-runtime"]]
}

View File

@@ -0,0 +1,5 @@
module.exports = {
e2e: {
IS_E2E: true
}
};

View File

@@ -0,0 +1,22 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module.exports = {
presets: ["@babel/preset-env"],
plugins: [["@babel/transform-runtime"]]
};

View File

@@ -19,6 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
const IS_E2E = process.env.IS_E2E === "true";
if (IS_E2E) console.log("Running e2e tests");
else console.log("Running non-e2e tests");
module.exports = {
// All imported modules in your tests should be mocked automatically
@@ -158,12 +162,10 @@ module.exports = {
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
testMatch: ["**/**/**/*.test.[jt]s?(x)"]
testMatch: ["**/**/**/*.test.[jt]s?(x)"],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
testPathIgnorePatterns: IS_E2E ? [] : ["/__e2e__/"]
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

View File

@@ -36,6 +36,7 @@
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"dotenv": "^16.0.1",
"env-cmd": "^10.1.0",
"eventsource": "^2.0.2",
"jest": "^28.1.3",
"jest-fetch-mock": "^3.0.3",
@@ -4915,6 +4916,31 @@
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/env-cmd": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz",
"integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==",
"dev": true,
"dependencies": {
"commander": "^4.0.0",
"cross-spawn": "^7.0.0"
},
"bin": {
"env-cmd": "bin/env-cmd.js"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/env-cmd/node_modules/commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
"dev": true,
"engines": {
"node": ">= 6"
}
},
"node_modules/error-ex": {
"version": "1.3.2",
"dev": true,
@@ -12302,6 +12328,24 @@
"entities": {
"version": "4.3.1"
},
"env-cmd": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz",
"integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==",
"dev": true,
"requires": {
"commander": "^4.0.0",
"cross-spawn": "^7.0.0"
},
"dependencies": {
"commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
"dev": true
}
}
},
"error-ex": {
"version": "1.3.2",
"dev": true,
@@ -13217,7 +13261,8 @@
},
"jest-pnp-resolver": {
"version": "1.2.2",
"dev": true
"dev": true,
"requires": {}
},
"jest-regex-util": {
"version": "28.0.2",
@@ -13760,7 +13805,8 @@
"dependencies": {
"ws": {
"version": "8.8.1",
"dev": true
"dev": true,
"requires": {}
}
}
},
@@ -14681,7 +14727,8 @@
}
},
"ws": {
"version": "7.5.9"
"version": "7.5.9",
"requires": {}
},
"xml-name-validator": {
"version": "4.0.0",

View File

@@ -22,12 +22,14 @@
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"dotenv": "^16.0.1",
"env-cmd": "^10.1.0",
"eventsource": "^2.0.2",
"jest": "^28.1.3",
"jest-fetch-mock": "^3.0.3",
"jsdom": "^20.0.0"
},
"scripts": {
"test:e2e": "env-cmd -e e2e jest --forceExit",
"test": "jest --forceExit"
},
"dependencies": {