-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-build.test.js
More file actions
31 lines (24 loc) · 1.08 KB
/
Copy pathtest-build.test.js
File metadata and controls
31 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { test } from 'node:test'
import assert from 'node:assert'
import { stat } from 'node:fs/promises'
import { join } from 'node:path'
import { testBuild } from './index.js'
const __dirname = join(import.meta.dirname, 'test-fixtures/test-build')
test.describe('testBuild', () => {
test('builds into a temporary directory and provides output helpers', async () => {
const src = join(__dirname, 'src')
const copy = join(__dirname, 'copyfolder')
const build = await testBuild(src, { copy: [copy] })
try {
assert.match(build.dest, /domstack-test-/, 'uses a domstack temp destination')
assert.ok(build.results, 'returns build results')
const html = await build.readOutput('index.html')
assert.match(html, /Test helper page/, 'reads generated page output')
const copied = await build.readOutput('copied.txt')
assert.strictEqual(copied, 'copied by testBuild\n', 'passes copy options through to DomStack')
} finally {
await build.cleanup()
}
await assert.rejects(stat(build.dest), 'cleanup removes the temporary destination')
})
})