Skip to content

Commit

Permalink
test(command-dev): pass offline flag by default (#2817)
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah authored Jul 1, 2021
1 parent f801d51 commit 1a19fcd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/command.dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1710,11 +1710,11 @@ export const handler = async function () {
await withDevServer(
{
cwd: builder.directory,
// we need to pass a token so the CLI tries to retrieve site information from the mock API
args: [...args, '--auth', 'fake-token'],
offline: false,
env: {
NETLIFY_API_URL: apiUrl,
NETLIFY_SITE_ID: 'site_id',
NETLIFY_AUTH_TOKEN: 'fake-token',
},
},
async ({ url }) => {
Expand Down
21 changes: 10 additions & 11 deletions tests/utils/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,22 @@ const FRAMEWORK_PORT_SHIFT = 1e3

let currentPort = getRandomPortStart()

const startServer = async ({ cwd, env = {}, args = [] }) => {
const startServer = async ({ cwd, offline = true, env = {}, args = [] }) => {
const tryPort = currentPort
currentPort += 1
const port = await getPort({ port: tryPort })
const host = 'localhost'
const url = `http://${host}:${port}`
console.log(`Starting dev server on port: ${port} in directory ${path.basename(cwd)}`)
// In CI we set a NETLIFY_AUTH_TOKEN which means the CLI will hit the live API in some cases
// as we don't need it for dev tests we can omit it
// eslint-disable-next-line no-unused-vars
const { NETLIFY_AUTH_TOKEN, ...processEnv } = process.env
const ps = execa(cliPath, ['dev', '-p', port, '--staticServerPort', port + FRAMEWORK_PORT_SHIFT, ...args], {
cwd,
extendEnv: false,
env: { ...processEnv, BROWSER: 'none', ...env },
encoding: 'utf8',
})
const ps = execa(
cliPath,
['dev', offline ? '--offline' : '', '-p', port, '--staticServerPort', port + FRAMEWORK_PORT_SHIFT, ...args],
{
cwd,
env: { BROWSER: 'none', ...env },
encoding: 'utf8',
},
)
let output = ''
const serverPromise = new Promise((resolve, reject) => {
let selfKilled = false
Expand Down

1 comment on commit 1a19fcd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 331 MB

Please sign in to comment.