Skip to content

Commit

Permalink
Add rollup test for createWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 10, 2021
1 parent 288edd4 commit 5d4e4c6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
17 changes: 17 additions & 0 deletions test/rollup/app-createWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createWorker } from "../../createWorker.mjs"
import { spawn, Thread } from "../../"

async function run() {
const add = await spawn(await createWorker("./worker.js", {backend: "node"}))
const result = await add(2, 3)
await Thread.terminate(add)
return result
}

run().then(result => {
console.log(`Result: ${result}`)
puppet.exit(0)
}).catch(error => {
console.error(error)
puppet.exit(1)
})
12 changes: 11 additions & 1 deletion test/rollup/rollup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ test("can be bundled using rollup", async t => {
...config
})

const appCreateWorkerBundleP = rollup({
input: path.resolve(__dirname, "app-createWorker.js"),
...config
})

const workerBundleP = rollup({
input: path.resolve(__dirname, "worker.js"),
...config
Expand All @@ -22,12 +27,17 @@ test("can be bundled using rollup", async t => {
format: "iife"
})

const appCreateWorkerBundleWriteP = (await appCreateWorkerBundleP).write({
dir: path.resolve(__dirname, "dist"),
format: "es"
})

const workerBundleWriteP = (await workerBundleP).write({
dir: path.resolve(__dirname, "dist"),
format: "iife"
})

await Promise.all([appBundleWriteP, workerBundleWriteP])
await Promise.all([appBundleWriteP, workerBundleWriteP, appCreateWorkerBundleWriteP])

if (process.platform === "win32") {
// Quick-fix for weird Windows issue in CI
Expand Down

0 comments on commit 5d4e4c6

Please sign in to comment.