Skip to content
Snippets Groups Projects
Unverified Commit e12da299 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Enable running a single spec in Cypress (#14942) (#14947)

Ports changes introduced in #14942 over to master branch
This is a cherry-pick of 70ad97a4.
parent 1d3ef4fd
No related branches found
No related tags found
No related merge requests found
......@@ -932,7 +932,7 @@ jobs:
<<: *CacheKeyUberjar
- steps: << parameters.before-steps >>
command: |
run test-cypress-no-build <<# parameters.only-single-database >> --testFiles << parameters.test-files-location >> <</ parameters.only-single-database >>
run test-cypress-no-build <<# parameters.only-single-database >> --folder << parameters.test-files-location >> <</ parameters.only-single-database >>
after-steps:
- store_artifacts:
path: /home/circleci/metabase/metabase/cypress
......
......@@ -7,13 +7,16 @@ const BackendResource = require("./backend.js").BackendResource;
const server = BackendResource.get({ dbKey: "" });
// We currently accept two (optional) command line arguments
// We currently accept three (optional) command line arguments
// --open - Opens the Cypress test browser
// --testFiles <path> - Specifies a different path for the integration folder
// --folder <path> - Specifies a different path for the integration folder
// --spec <single-spec-path> - Specifies a path to a single test file
const userArgs = process.argv.slice(2);
const isOpenMode = userArgs.includes("--open");
const testFiles = userArgs.includes("--testFiles");
const testFilesLocation = userArgs[userArgs.indexOf("--testFiles") + 1];
const sourceFolder = userArgs.includes("--folder");
const singleFile = userArgs.includes("--spec");
const sourceFolderLocation = userArgs[userArgs.indexOf("--folder") + 1];
const singleFileName = userArgs[userArgs.indexOf("--spec") + 1];
function readFile(fileName) {
return new Promise(function(resolve, reject) {
......@@ -35,8 +38,12 @@ const init = async () => {
);
}
if (testFiles) {
console.log(chalk.bold(`Running tests in '${testFilesLocation}'`));
if (sourceFolder) {
console.log(chalk.bold(`Running tests in '${sourceFolderLocation}'`));
}
if (singleFile) {
console.log(chalk.bold(`Running single spec '${singleFileName}'`));
}
try {
......@@ -67,8 +74,10 @@ const init = async () => {
console.log(chalk.bold("Starting Cypress"));
let commandLineConfig = `baseUrl=${server.host}`;
if (testFiles) {
commandLineConfig = `${commandLineConfig},integrationFolder=${testFilesLocation}`;
if (sourceFolder) {
commandLineConfig = `${commandLineConfig},integrationFolder=${sourceFolderLocation}`;
} else if (singleFile) {
commandLineConfig = `${commandLineConfig},testFiles=${singleFileName}`;
} else {
// if we're not running specific tests, avoid including db and smoketests
commandLineConfig = `${commandLineConfig},ignoreTestFiles=**/metabase-{smoketest,db}/**`;
......
......@@ -11,7 +11,7 @@ From the root of the repository:
- If you already have built Metabase with `./bin/build`, just run this to run all the tests.
```shell
yarn run test-cypress-no-build --testFiles frontend/test/metabase-smoketest
yarn run test-cypress-no-build --folder frontend/test/metabase-smoketest
```
- Active development, add `--open`
\ No newline at end of file
......@@ -196,7 +196,7 @@
"test-cypress-open": "./bin/build-for-test && yarn test-cypress-no-build --open",
"test-cypress-open-no-backend": "E2E_HOST='http://localhost:3000' yarn test-cypress-no-build --open",
"test-cypress-no-build": "yarn && CONFIG_FILE=frontend/test/cypress.json babel-node ./frontend/test/__runner__/run_cypress_tests.js",
"test-cypress-smoketest": "yarn test-cypress-no-build --testFiles frontend/test/metabase-smoketest"
"test-cypress-smoketest": "yarn test-cypress-no-build --folder frontend/test/metabase-smoketest"
},
"lint-staged": {
"frontend/**/*.{js,jsx,css}": [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment