Vuejs - How to add e2e/unit tests after not including them initially in the creation of the webpack project?

Asked

Viewed 90 times

0

I own a project that was started with vuetify webpack (Vue init vuetifyjs/webpack). At the time the project was created, the e2e/unit test option was not selected. However, there is now a need to perform the tests.

I checked the manual installation of Nightwatch first, and installed all the necessary dependencies via npm, for example:

npm install --save-dev webpack-dev-server
npm i -D babel-register chromedriver cross-spawn nightwatch selenium-server

Insert in script too, so it can be executed:

"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e"`

However, errors occur through the file webpack.dev.conf.js. It turns out that devConfigPromise.then(devConfig => { TypeError: devConfigPromise.then is not a function, and really it is not, because to check created another project today from scratch and the file webpack.dev.conf.js is extremely different from mine, as well as he owns the export of a Promise, among other new dependencies, which is necessary to resolve this error of devConfigPromise use the .then.

I would like to know if anyone has ever been in a situation like this, and knows of any relatively easy solution to this case, because I tried to "integrate" the webpack.dev.conf.js of the new project in my old, but there are several problems, and I have reached a point that I no longer know how to solve.

I tried to look, but I haven’t found anything about it so far, which in my view is strange, because otherwise it ends up like this: Either you start the project with tests, or you create another.

If it helps, I can post the code of the configuration files, in the case of this project there are three for development, the webpack.dev.conf.js, the dev-client.js and the dev-server.js.

1 answer

0


I found the answer on stackoverflow NA which was answered two days ago on the link: https://stackoverflow.com/questions/48361246/vue-how-do-you-add-e2e-tests-after-not-including-them-in-initial-webpack-templa/49882074#49882074

Briefly explaining the solution to those with the same problem, first you should find the Boilerplate (or template) that corresponds to the version your project is in. Luckily, in my case I was in version 1.1.0 and the template in the reply is the same.

If it is not, check the version of Boilerplate you are using and look for start (or some project started) with the e2e test option. Then copy the entire folder test for your project. Done this, add e2e and test in the script as stated in the reply and install the dependencies chromedriver eSelenium-server(talvez tenha que instalar awebpack-dev-server) como modo desenvolvimento, no caso do npm seria com a flag--save-dev`.

I haven’t quite got to the bottom of the tests yet, but apparently you did, at least in the case of e2e with nightwatch.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.