-
Notifications
You must be signed in to change notification settings - Fork 406
Expand file tree
/
Copy pathindex.spec.js
More file actions
77 lines (61 loc) · 2.32 KB
/
Copy pathindex.spec.js
File metadata and controls
77 lines (61 loc) · 2.32 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
/* eslint-disable no-console */
'use strict'
const chproc = require('node:child_process')
const pathModule = require('node:path')
const fs = require('node:fs')
const { describe, before, after, it } = require('mocha')
// sub process must be executed inside TEST_DIR
const TEST_DIR = pathModule.join(__dirname, '.')
const execSync = (command, options) => {
console.log(command)
chproc.execSync(command, { ...(options ?? {}), cwd: TEST_DIR })
}
const rmSync = (filePath, options) => fs.rmSync(pathModule.join(TEST_DIR, filePath), options)
const originalDir = process.cwd()
// Test with two webpack 5 versions: an older one and the latest
// Note: webpack 5.0.0 hardcodes "md4" in FileSystemInfo, incompatible with
// OpenSSL 3 (Node 18+). 5.54.0 is the first version where FileSystemInfo
// reads output.hashFunction, allowing sha256 to be used instead.
const webpackVersions = ['5.54.0', '5']
const timeout = 1000 * 60
webpackVersions.forEach((version) => {
describe(`webpack ${version}`, function () {
this.timeout(timeout)
before(() => {
process.chdir(TEST_DIR)
execSync('npm install', { timeout })
execSync(`npm install webpack@${version}`, { timeout })
})
after(() => {
process.chdir(originalDir)
execSync('npm remove webpack', { timeout })
})
it('works', () => {
execSync('npm run build', { timeout })
try {
execSync('npm run built', { timeout })
} catch (err) {
console.error(err)
process.exit(1)
} finally {
rmSync('./out.js', { force: true })
}
})
it('does not bundle modules listed in externals', () => {
execSync('node ./build-and-test-skip-external.js', { timeout })
})
it('does not follow `@datadog/openfeature-node-server` into its optional peer chain', () => {
execSync('node ./build-and-test-openfeature.js', { timeout })
})
it('preserves application externals and bundles API fallbacks after relocation', () => {
execSync('node ./build-and-test-otel-api.js', { timeout })
})
it('injects Git metadata into bundled applications', () => {
execSync('node ./build-and-test-git-tags.js', { timeout })
})
it('prints error when user enables optimization.minimize', () => {
execSync('node ./build-and-test-minify.js', { timeout })
})
})
})