-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
"nuxt start-dev" or similar for integration testing #5719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi. You can set an env variable during build like this: {
env: {
STAGE: process.env.STAGE
}
} And then align runtime behavior according to it. Like disabling redirects. |
Hi @pi0 - thanks for the workaround... I will certainly take a look. I believe my case is a common enough use case that it might warrant a deeper look, however. |
For integration testing, I believe it is best practice to keep it consistent and as much as possible near to production environment. Even something like HTTPS should be testable (something may be broken only via https protocol) The |
OK - thanks for the explanation. Instead, then, (assuming I want to continue testing in dev mode) would it be possible to create a version of |
@pedantic-git I can probably help better if have an example when you need A preview of what happens if we combine
module.exports = function() {
if (!this.options.dev && process.argv.find(a => a === '--dev')) {
this.options.dev = true
}
} And register in export default {
modules: [
'~/modules/dev.js'
]
} Then when running |
I think it's perhaps just a misalignment of what I mean by 'integration test'. My Rails app that provides the API is running in 'test' mode, which can be configured separately from dev and production, and I would ideally like the Nuxt app that runs alongside it to be configured in the same way. For example, I know I don't care about SSL, so I would like the But Capybara (a Ruby web browser for tests) starts the Rails app on a custom port so there's not really any way to start Nuxt until after the tests begin executing, and it only gives 60 seconds for any servers to start up, which is sometimes not long enough to start Nuxt. In my mind, the solution to this was to separate the build and start steps for this 'test mode' Nuxt so that we're not waiting for the compilation during application startup, but you may have an alternative idea! I believe this is (or should be) quite a common use case for a Nuxt app with a backend written in another language/framework. Your workaround above might well be what I need for now, but I'd like to explore the possibility of something more "official"? |
@pedantic-git Can add a CI step before tests to do How do you register |
@pi0 It's registered like this:
I can't readily find the docs to conditionally disable it using an env. The other envs that are an issue are API_URL / API_URL_BROWSER (from @nuxtjs/axios) which will change depending on the run env. If they can only be set during the build it's probably OK for me to rewrite the backend test so it always runs on the same port instead of a random one. |
(PS. Thank you so much for your help and understanding so far! Once this is done I promise I'll write it up in some form for others to take advantage of.) |
@pi0 question, if I run |
To anyone who stumbles on this, when running |
What problem does this feature solve?
I'm building a full-stack PWA which has full-stack integration tests. Currently in those integration tests, Nuxt is running in full 'dev' mode which means the following:
An alternative would be to run
nuxt build
before starting the tests and thennuxt start
for testing the app. The problems are:nuxt start
forces thedev
flag to false, meaning that the app cannot run without ssl if the redirect-ssl middleware is installed (for example)nuxt build
hardcodes the values of environment variables at the time the app was built, which in my case will be before I know whatAPI_URL
(for@nuxtjs/axios
should be)What does the proposed changes look like?
A new command
nuxt start-dev
ornuxt start-test
that is the same asnuxt start
except:dev
flag is set to true, andWhat do you think? If you like the idea, let me know how I can help!
The text was updated successfully, but these errors were encountered: