Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('dehydation', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs'),
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
function testForFile (name, file = name) {
test(name, () => {
const html = readFileSync(resolve(app.outDir, file), 'utf8')
expect(html).toMatchSnapshot()
})
}
testForFile('404.html')
describe('plugin-public-files: source folder', () => {
const app = createApp({
sourceDir: resolve(__dirname, 'docs-1')
})
beforeAll(async () => {
await app.process()
await app.build()
}, 60000)
testForExistence(app, 'foo.txt')
testForExistence(app, 'baz.txt')
testForExistence(app, 'bar/foo.txt')
testForExistence(app, 'bar/baz.txt')
testForExistence(app, 'index.html')
testForExistence(app, 'readme.md', false)
testForExistence(app, '.dotfile', false)
testForExistence(app, '.dotfolder', false)
async beforeParse (subCli) {
const app = createApp({
sourceDir: sourceDir,
...options,
...commandoptions
})
await app.process()
app.pluginAPI.applySyncOption('extendCli', subCli, app)
console.log()
},
async afterParse (subCli) {
logger.developer('needPrepareBeforeLaunchCLI', needPrepareBeforeLaunchCLI)
if (needPrepareBeforeLaunchCLI) {
let app
let [, sourceDir] = argv
if (!sourceDir || sourceDir.startsWith('-')) {
sourceDir = inferredUserDocsDirectory
} else {
sourceDir = pwd
}
logger.setOptions({ logLevel: 1 })
if (sourceDir) {
app = createApp({ sourceDir, ...options })
await app.process()
app.pluginAPI.applySyncOption('extendCli', cli, app)
}
logger.setOptions({ logLevel: 3 })
}
}