diff options
author | 2021-04-22 08:25:57 -0400 | |
---|---|---|
committer | 2021-04-22 08:25:57 -0400 | |
commit | da033e27eada3bbcad5544be282e9edcf4799003 (patch) | |
tree | 8fa1203d4e318f006d254abff79caa2508a86fd2 /test/config-port.test.js | |
parent | a7185735da7413e132f313ff5086db74304d7654 (diff) | |
download | astro-da033e27eada3bbcad5544be282e9edcf4799003.tar.gz astro-da033e27eada3bbcad5544be282e9edcf4799003.tar.zst astro-da033e27eada3bbcad5544be282e9edcf4799003.zip |
CLI docs (#121)
* Start of cli docs
* Document the CLI
Also adds support for the `--config` option and `--port` option for the dev server.
* Add tests for --config and --port flags
* Add port to validateConfig
Diffstat (limited to 'test/config-port.test.js')
-rw-r--r-- | test/config-port.test.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/config-port.test.js b/test/config-port.test.js new file mode 100644 index 000000000..9b5f7b14c --- /dev/null +++ b/test/config-port.test.js @@ -0,0 +1,29 @@ +import { suite } from 'uvu'; +import * as assert from 'uvu/assert'; +import { runDevServer } from './helpers.js'; +import { loadConfig } from '../lib/config.js'; + +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(root.pathname); + 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(/Server running at/.test(chunk)) { + assert.ok(/:3002/.test(chunk), 'Using the right port'); + break; + } + } + + process.kill(); +}); + +ConfigPort.run(); |