-
Notifications
You must be signed in to change notification settings - Fork 83
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
ctx.nuxt
does not exist when build: false
in setup
#918
Comments
Hey, @nopeless! I'm here to help you with bugs, answer questions, and guide you toward becoming a contributor. While you're waiting for a human maintainer, I'm available to assist you. The issue with
Here is a modified version of the export async function startServer(options: StartServerOptions = {}) {
const ctx = useTestContext();
await stopServer();
const host = '127.0.0.1';
const port = ctx.options.port || await getRandomPort(host);
ctx.url = `http://${host}:${port}/`;
if (!ctx.nuxt) {
throw new Error('ctx.nuxt is not defined. Ensure that the context is properly initialized.');
}
if (ctx.options.dev) {
const nuxiCLI = await kit.resolvePath('nuxi/cli');
ctx.serverProcess = execa(nuxiCLI, ['_dev'], {
cwd: ctx.nuxt.options.rootDir,
stdio: 'inherit',
env: {
...process.env,
_PORT: String(port), // Used by internal _dev command
PORT: String(port),
HOST: host,
NODE_ENV: 'development',
...options.env,
...ctx.options.env,
},
});
await waitForPort(port, { retries: 32, host }).catch(() => {});
let lastError;
for (let i = 0; i < 150; i++) {
await new Promise(resolve => setTimeout(resolve, 100));
try {
const res = await $fetch<string>(ctx.nuxt.options.app.baseURL, { responseType: 'text' });
if (!res.includes('__NUXT_LOADING__')) {
return;
}
} catch (e) {
lastError = e;
}
}
ctx.serverProcess.kill();
throw lastError || new Error('Timeout waiting for dev server!');
} else {
ctx.serverProcess = execa('node', [
resolve(ctx.nuxt.options.nitro.output!.dir!, 'server/index.mjs'),
], {
stdio: 'inherit',
env: {
...process.env,
PORT: String(port),
HOST: host,
NODE_ENV: 'test',
...options.env,
...ctx.options.env,
},
});
await waitForPort(port, { retries: 20, host });
}
} This modification ensures |
I am willing to provide stackblitz repro if required |
Environment
N/A
Reproduction
N/A
Describe the bug
setup fails
Additional context
cc: @tobiasdiez
Here are the lines
test-utils/src/core/server.ts
Lines 17 to 71 in 86d09da
offending line for me was 57, but could easily be any other lines
c4df41d
is the offending commit
specifically this change
c4df41d#diff-84e9c1e393b43cee97ce99909a2db3a09bf9a2435daa2066b01a838e206edec3
Logs
The text was updated successfully, but these errors were encountered: