Skip to content

[VEG-871] Remove wait by spying on setAppAssetsMiddleware #91

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/zcli-apps/tests/functional/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect, test } from '@oclif/test'
import * as path from 'path'
import * as http from 'http'
import fetch from 'node-fetch'
import { promises as fsPromise } from 'fs'
import * as fs from 'fs'
import { omit } from 'lodash'
import ServerCommand from '../../src/commands/apps/server'
Expand Down Expand Up @@ -105,16 +106,17 @@ describe('apps server', function () {
const manifest: Manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
const appName = manifest.name
manifest.name = `${appName} modified`
// Modifed manifest.json
fs.writeFileSync(manifestPath, JSON.stringify(manifest))
await wait()
// Modify manifest.json
await fsPromise.writeFile(manifestPath, JSON.stringify(manifest))
// Wait for setAppAssetsMiddleware() spy to be called to ensure that change has been written
// TODO implement spy on said method here and/or however this works in Cypress / Puppeteer perhaps on the route
const response = await fetch(`${appHost}/app.json`)
appsJSON = await response.json()
const appJSON = appsJSON.apps[index]
expect(appJSON.name).to.eq(`${appName} modified`)
// Restored manifest.json
// Restore manifest.json
manifest.name = appName
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2))
await fsPromise.writeFile(manifestPath, JSON.stringify(manifest, null, 2))
}))
})
})
Expand Down