MCPcopy Index your code
hub / github.com/ds300/patch-package / runIntegrationTest

Function runIntegrationTest

integration-tests/runIntegrationTest.ts:14–97  ·  view source on GitHub ↗
({
  projectName,
  shouldProduceSnapshots,
}: {
  projectName: string
  shouldProduceSnapshots: boolean
})

Source from the content-addressed store, hash-verified

12)
13
14export function runIntegrationTest({
15 projectName,
16 shouldProduceSnapshots,
17}: {
18 projectName: string
19 shouldProduceSnapshots: boolean
20}) {
21 describe(`Test ${projectName}:`, () => {
22 const tmpDir = tmp.dirSync({ unsafeCleanup: true })
23 fs.copySync(join(__dirname, projectName), tmpDir.name, {
24 recursive: true,
25 })
26
27 // remove node_modules folder when running locally, to avoid leaking state from source dir
28 rimraf.sync(join(tmpDir.name, "node_modules"))
29
30 const packageJson = require(join(tmpDir.name, "package.json"))
31 packageJson.dependencies = resolveRelativeFileDependencies(
32 join(__dirname, projectName),
33 packageJson.dependencies,
34 )
35
36 fs.writeFileSync(
37 join(tmpDir.name, "package.json"),
38 JSON.stringify(packageJson),
39 )
40
41 const result = spawnSafeSync(
42 `./${projectName}.sh`,
43 [patchPackageTarballPath],
44 {
45 cwd: tmpDir.name,
46 throwOnError: false,
47 env: {
48 ...process.env,
49 PATCH_PACKAGE_INTEGRATION_TEST: "1",
50 },
51 shell: true,
52 },
53 )
54
55 it("should exit with 0 status", () => {
56 expect(result.status).toBe(0)
57 })
58
59 const output = result.stdout.toString() + "\n" + result.stderr.toString()
60
61 if (result.status !== 0) {
62 console.log(output)
63 }
64
65 it("should produce output", () => {
66 expect(output.trim()).toBeTruthy()
67 })
68
69 const snapshots = output.match(/SNAPSHOT: ?([\s\S]*?)END SNAPSHOT/g)
70
71 if (shouldProduceSnapshots) {

Calls 3

joinFunction · 0.90
spawnSafeSyncFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…