astro/packages/astro/test/config-port.test.js
Drew Powers 9d092b56c7
Fix Windows tests (#212)
* Fix Windows fetchContent()

* Fix Windows bundling & config loading

* Fix astro-prettier formatting for Windows
2021-05-14 12:03:41 -04:00

31 lines
883 B
JavaScript

import { fileURLToPath } from 'url';
import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { runDevServer } from './helpers.js';
import { loadConfig } from '#astro/config';
const ConfigPort = suite('Config path');
const root = new URL('./fixtures/config-port/', import.meta.url);
ConfigPort('can be specified in the astro config', async (context) => {
const astroConfig = await loadConfig(fileURLToPath(root));
assert.equal(astroConfig.devOptions.port, 3001);
});
ConfigPort('can be specified via --port flag', async (context) => {
const args = ['--port', '3002'];
const process = runDevServer(root, args);
process.stdout.setEncoding('utf8');
for await (const chunk of process.stdout) {
if (/Local:/.test(chunk)) {
assert.ok(/:3002/.test(chunk), 'Using the right port');
break;
}
}
process.kill();
});
ConfigPort.run();