Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihweiLHBird committed Nov 4, 2024
1 parent 135e0ad commit 7ad0c77
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/winglang/src/commands/test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from "path";
import { BuiltinPlatform } from "@winglang/compiler";
import { LogLevel, TestResult, TraceType } from "@winglang/sdk/lib/std";
import chalk from "chalk";
import { describe, test, expect, beforeEach, afterEach, vi, SpyInstance } from "vitest";
import { describe, test, expect, beforeEach, afterEach, vi, MockInstance } from "vitest";
import { filterTests, renderTestReport, collectTestFiles, test as wingTest } from ".";
import * as resultsFn from "./results";
import { SnapshotMode } from "./snapshots";
Expand Down Expand Up @@ -45,10 +45,17 @@ describe("printing test reports", () => {
expect(testReport).toMatchSnapshot();
expect(testReport).toContain("Push (message=cool)");
});

test("results for files with no tests", async () => {
const testReport = await renderTestReport("hello.w", []);
expect(testReport).toMatchSnapshot();
expect(testReport).toContain("Tests 0 passed (0)");
});

});

describe("wing test (custom platform)", () => {
let logSpy: SpyInstance;
let logSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down Expand Up @@ -208,7 +215,7 @@ describe("collectTestFiles", () => {
});

describe("output-file option", () => {
let writeResultsSpy: SpyInstance;
let writeResultsSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down Expand Up @@ -304,7 +311,7 @@ describe("test-filter option", () => {
});

describe("retry and parallel options", () => {
let logSpy: SpyInstance;
let logSpy: MockInstance;

beforeEach(() => {
chalk.level = 0;
Expand Down

0 comments on commit 7ad0c77

Please sign in to comment.