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 2b27588
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 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,21 @@ describe("printing test reports", () => {
expect(testReport).toMatchSnapshot();
expect(testReport).toContain("Push (message=cool)");
});

test("results for files with no tests", async () => {
let inputResults: TestResult[] = [];
const testReport = await renderTestReport("hello.w", inputResults);
expect(testReport).toMatchSnapshot();
expect(testReport).toContain("(no tests)");

// verify that the the no dummy test results were added
expect(inputResults).toHaveLength(0);
});

});

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

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

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

beforeEach(() => {
chalk.level = 0;
Expand Down Expand Up @@ -304,7 +315,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 2b27588

Please sign in to comment.