Correcting the port

In order to run the test against the URL through port 8080, we will need to ask @vue/cli-service to not start the dev server by providing a --url parameter to the command, like the following:

"scripts": {
...
"test:e2e": "vue-cli-service test:e2e",
"test:integration": "vue-cli-service test:e2e --url http://localhost:8080/",
...
},

Then, let's change the execution of the integration test in pom.xml to the following:

<execution>
<id>frontend e2e test</id>
...
<configuration>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>test:integration</argument>
</arguments>
</configuration>
</execution>

In this way, with the npm test command, we will still run tests against http://localhost:3000 and, with the mvn clean install command, we run tests against http://localhost:8080.

After that, we need to add frontend/nightwatch.config.js to specify launch_url, as follows:

module.exports = {
test_settings: {
default: {
launch_url: (process.env.LAUNCH_URL || process.env.VUE_DEV_SERVER_URL)
}
}
}

The launch URL passed in the test:integration script will be set to process.env.LAUNCH_URL. In this way, Nightwatch will pick up the correct URL when we run npm run test:e2e and npm run test:integration. One last change is login.e2e.js. With the setting in nightwatch.config.js, we will need to get the launch URL via browser.launchUrl:

'login test': function (browser) {
browser
.url(browser.launchUrl + 'login')
...
}

Now, if you run mvn clean install, you can see the integration is performed against http://localhost:8080.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.75.165