From bfebc6d934926c9080b09107c13ede5dca4d6bab Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Mon, 4 Jun 2018 17:08:50 +0200 Subject: [PATCH] fix(ui): tests --- packages/@vue/cli-ui/package.json | 8 +++++--- packages/@vue/cli-ui/src/graphql-api/utils/db.js | 2 +- packages/@vue/cli-ui/vue-cli-ui.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/@vue/cli-ui/package.json b/packages/@vue/cli-ui/package.json index 7516dab65b..23fc4e4df2 100644 --- a/packages/@vue/cli-ui/package.json +++ b/packages/@vue/cli-ui/package.json @@ -7,12 +7,13 @@ "lint": "vue-cli-service lint", "graphql-api": "cross-env VUE_CLI_DEBUG=true VUE_CLI_UI_DEV=true vue-cli-service graphql-api", "run-graphql-api": "vue-cli-service run-graphql-api", - "run-test-graphql-api": "cross-env NODE_ENV=test VUE_APP_GRAPHQL_PORT=4040 VUE_APP_CLI_UI_URL=ws://localhost:4040/graphql yarn run graphql-api", + "test-graphql-api": "cross-env VUE_CLI_UI_TEST=true VUE_APP_GRAPHQL_PORT=4040 VUE_APP_CLI_UI_URL=ws://localhost:4040/graphql yarn run graphql-api", "prepublishOnly": "yarn run lint --no-fix && yarn run build", "test:e2e:dev": "cross-env VUE_APP_CLI_UI_URL=ws://localhost:4040/graphql vue-cli-service test:e2e --mode development", "test:e2e:run": "vue-cli-service test:e2e --mode production --headless --url=http://localhost:4040", - "test:e2e": "start-server-and-test run-test-graphql-api http://localhost:4040 test:e2e:dev", - "test:run": "start-server-and-test run-test-graphql-api http://localhost:4040 test:e2e:run", + "test:e2e": "yarn run test:clear && start-server-and-test test-graphql-api http://localhost:4040 test:e2e:dev", + "test:run": "yarn run test:clear && start-server-and-test test-graphql-api http://localhost:4040 test:e2e:run", + "test:clear": "rimraf ../../test/cli-ui-test && rimraf ./live-test", "test": "yarn run build && cd ../cli-ui-addon-webpack && yarn run build && cd ../cli-ui && yarn run test:run" }, "dependencies": { @@ -56,6 +57,7 @@ "file-icons-js": "^1.0.3", "lint-staged": "^6.0.0", "portal-vue": "^1.3.0", + "rimraf": "^2.6.2", "start-server-and-test": "^1.4.1", "stylus": "^0.54.5", "stylus-loader": "^3.0.1", diff --git a/packages/@vue/cli-ui/src/graphql-api/utils/db.js b/packages/@vue/cli-ui/src/graphql-api/utils/db.js index 9253560b83..10a7e8ee13 100644 --- a/packages/@vue/cli-ui/src/graphql-api/utils/db.js +++ b/packages/@vue/cli-ui/src/graphql-api/utils/db.js @@ -5,7 +5,7 @@ const { resolve } = require('path') let folder = '../../../live' -if (process.env.NODE_ENV === 'test') { +if (process.env.VUE_CLI_UI_TEST) { folder = '../../../live-test' // Clean DB fs.removeSync(resolve(__dirname, folder)) diff --git a/packages/@vue/cli-ui/vue-cli-ui.js b/packages/@vue/cli-ui/vue-cli-ui.js index d37ab546a8..efa84d21bf 100644 --- a/packages/@vue/cli-ui/vue-cli-ui.js +++ b/packages/@vue/cli-ui/vue-cli-ui.js @@ -1,6 +1,6 @@ // This file will be loaded when the project is opened module.exports = api => { - if (process.env.NODE_ENV === 'production') return + if (!process.env.VUE_CLI_UI_DEV) return // Add dynamic components in dev mode (webpack dashboard & analyzer) api.addClientAddon({