Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove test dependency #239

Merged
merged 4 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Node.js & TypeScript",
"image": "mcr.microsoft.com/devcontainers/typescript-node:16-bullseye",
"image": "mcr.microsoft.com/devcontainers/typescript-node:20",
"features": {},
"forwardPorts": [],
"postCreateCommand": "yarn install",
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ this by setting the `private` property in `package.json` to `false`.

_Scope: repo or workspace_

This plugin enables testing with the [test](https://www.npmjs.com/package/test)
package, which is a port of the native
[node:test](https://nodejs.org/api/test.html) which is only available in Node
≥ 18. It uses [tap](https://node-tap.org) for formatting the TAP output.
This plugin enables testing with the native
[node --test](https://nodejs.org/api/test.html) functionality. It uses
[tap](https://node-tap.org) for formatting the TAP output.

When the `typescript` plugin is also installed, it will use
[ts-node](https://typestrong.org/ts-node/) to load TypeScript test files.
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Filename | line # | TODO |
| :------------------------------------------------------------------------- | :----: | :--------------------------------------------------------------- |
| [packages/cli/test/add.test.ts](packages/cli/test/add.test.ts#L55) | 55 | remove when https://github.com/nodejs/node/issues/47614 resolves |
| [packages/cli/test/add.test.ts](packages/cli/test/add.test.ts#L52) | 52 | remove when https://github.com/nodejs/node/issues/47614 resolves |
| [packages/core/src/license.ts](packages/core/src/license.ts#L43) | 43 | Contents is not perfect yet, e.g.: |
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later |
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L31) | 31 | install jest without ts-jest |
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean": "rm -rf dist && rm -rf types",
"prepublish": "yarn build && cp ../../README.md .",
"start": "node moker.js",
"test": "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node--test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage"
"test": "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node --test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage"
},
"dependencies": {
"@mokr/core": "workspace:*",
Expand All @@ -30,7 +30,6 @@
"devDependencies": {
"@types/node": "20.6.2",
"tap": "16.3.8",
"test": "3.3.0",
"ts-node": "10.9.1",
"typescript": "5.2.2"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/test/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { createDirectory, isDirectory, writePackage } from "@mokr/core";
import assert from "node:assert";
import { beforeEach, describe, it } from "node:test";
import { temporaryDirectory } from "tempy";
import test from "test";
import cli from "../src/cli.js";

/* @ts-expect-error */
const { describe, beforeEach, it } = test;

describe("add", () => {
let tempDir: string;

Expand Down
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build:watch": "tsc --watch",
"clean": "rm -rf dist && rm -rf types",
"prepublish": "yarn build",
"test": "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node--test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage"
"test": "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node --test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage"
},
"dependencies": {
"chalk": "5.3.0",
Expand All @@ -34,7 +34,6 @@
"@types/node": "20.6.2",
"tap": "16.3.8",
"tempy": "3.1.0",
"test": "3.3.0",
"ts-node": "10.9.1",
"typescript": "5.2.2"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/io.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import assert from "node:assert";
import test from "test";
import { beforeEach, describe, it } from "node:test";
import { hasEncounteredErrors, resetState, task } from "../src/io.js";

/* @ts-expect-error */
const { beforeEach, describe, it } = test;

describe("task", () => {
beforeEach(() => resetState());

Expand Down
5 changes: 1 addition & 4 deletions packages/core/test/json.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import assert from "node:assert";
import { writeFileSync } from "node:fs";
import { describe, it } from "node:test";
import { temporaryFile } from "tempy";
import test from "test";
import { readJson } from "../src/json.js";

/* @ts-expect-error */
const { describe, it } = test;

describe("readJson", () => {
it("should read a JSON file", async () => {
const path = temporaryFile();
Expand Down
8 changes: 4 additions & 4 deletions packages/plugins/src/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function install({ directory }: PluginArgs) {

enqueueInstallDependency({
directory,
identifier: ["test", "tap"],
identifier: ["tap"],
dev: true,
});

Expand All @@ -23,7 +23,7 @@ async function install({ directory }: PluginArgs) {
directory,
data: {
scripts: {
test: "node--test | tap --no-coverage",
test: "node --test | tap --no-coverage",
},
},
});
Expand All @@ -38,7 +38,7 @@ async function install({ directory }: PluginArgs) {
directory,
data: {
scripts: {
test: "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node--test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage",
test: "NODE_OPTIONS='--loader=ts-node/esm --no-warnings' node --test test/*.test.ts | NODE_OPTIONS='--loader=ts-node/esm --no-warnings' tap --no-coverage",
},
},
});
Expand All @@ -57,7 +57,7 @@ async function install({ directory }: PluginArgs) {
}

async function remove({ directory }: PluginArgs) {
enqueueRemoveDependency({ directory, identifier: ["test", "ts-node"] });
enqueueRemoveDependency({ directory, identifier: ["tap", "ts-node"] });

warning("Please review package.json manually");
}
Expand Down
8 changes: 5 additions & 3 deletions packages/templates/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { join } from "path";

async function apply({ directory }: TemplateArgs) {
await installPlugin({ directory, name: "typescript" });
await installPlugin({ directory, name: "jest" });
await installPlugin({ directory, name: "test" });

await writeFile({
path: join(directory, "src/sum.ts"),
Expand All @@ -25,12 +25,14 @@ export function sum(a: number, b: number) {
});

await writeFile({
path: join(directory, "tests/sum.test.ts"),
path: join(directory, "test/sum.test.ts"),
contents: `
import assert from "node:assert";
import test from "node:test";
import { sum } from "../src/sum.js";

test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
assert.strictEqual(sum(1, 2), 3);
});
`,
});
Expand Down
Loading