Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(@turbo/repository): convert tests to node test runner (#7985)
Running these tests with Jest takes ~15s, with test runner it takes ~400ms. The test execution itself is the same, so I think the extra time for Jest is because of transpiling via Babel? Maybe there's an import that is slow or something that is irrelevant with `node --import`.
- Loading branch information
Showing
7 changed files
with
26 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
import { describe, it } from "node:test"; | ||
import { strict as assert } from "node:assert"; | ||
import * as path from "node:path"; | ||
import { Workspace, Package } from "../js/dist/index.js"; | ||
|
||
describe("findPackages", () => { | ||
it("enumerates packages", async () => { | ||
const workspace = await Workspace.find("./fixtures/monorepo"); | ||
const packages: Package[] = await workspace.findPackages(); | ||
expect(packages.length).not.toBe(0); | ||
assert.notEqual(packages.length, 0); | ||
}); | ||
|
||
it("returns a package graph", async () => { | ||
const dir = path.resolve(__dirname, "./fixtures/monorepo"); | ||
const workspace = await Workspace.find(dir); | ||
const packages = await workspace.findPackagesWithGraph(); | ||
|
||
expect(Object.keys(packages).length).toBe(2); | ||
assert.equal(Object.keys(packages).length, 2); | ||
|
||
const pkg1 = packages["apps/app"]; | ||
const pkg2 = packages["packages/ui"]; | ||
|
||
expect(pkg1.dependencies).toEqual(["packages/ui"]); | ||
expect(pkg1.dependents).toEqual([]); | ||
assert.deepEqual(pkg1.dependencies, ["packages/ui"]); | ||
assert.deepEqual(pkg1.dependents, []); | ||
|
||
expect(pkg2.dependencies).toEqual([]); | ||
expect(pkg2.dependents).toEqual(["apps/app"]); | ||
assert.deepEqual(pkg2.dependencies, []); | ||
assert.deepEqual(pkg2.dependents, ["apps/app"]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { describe, it } from "node:test"; | ||
import { strict as assert } from "node:assert"; | ||
import * as path from "node:path"; | ||
import { Workspace, PackageManager } from "../js/dist/index.js"; | ||
|
||
describe("Workspace", () => { | ||
it("finds a workspace", async () => { | ||
const workspace = await Workspace.find(); | ||
const expectedRoot = path.resolve(__dirname, "../../.."); | ||
expect(workspace.absolutePath).toBe(expectedRoot); | ||
assert.equal(workspace.absolutePath, expectedRoot); | ||
}); | ||
|
||
it("finds a package manager", async () => { | ||
const workspace = await Workspace.find(); | ||
const packageManager: PackageManager = workspace.packageManager; | ||
expect(packageManager.name).toBe("pnpm"); | ||
assert.equal(packageManager.name, "pnpm"); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.