anggoran
anggoran•7mo ago

Managing Test Scripts

How to manage multiple test scripts so they will be detected on the Test Explorer?
2 Replies
anggoran
anggoranOP•7mo ago
is this a good practice?
// main_test.ts
import { createHandler, ServeHandlerInfo } from "$fresh/server.ts";
import manifest from "../fresh.gen.ts";
import config from "../fresh.config.ts";
import * as listening from "./listening.ts";
import * as reading from "./reading.ts";

export const CONNECTION: ServeHandlerInfo = {
remoteAddr: { hostname: "localhost", port: 8000, transport: "tcp" },
};
export const handler = await createHandler(manifest, config);

Deno.test("Feature: Listening Pinyin", async (t) => {
await t.step("Get the question", listening.getQuestion);
await t.step("Post the answer", listening.postAnswer);
await t.step("Get the correct state", listening.getCorrectState);
await t.step("Get the false state", listening.getFalseState);
});

Deno.test("Feature: Reading Hanzi", async (t) => {
await t.step("Render creation form", reading.renderCreationForm);
await t.step("Start a quiz", reading.startQuiz);
await t.step("Post the answer", reading.postAnswer);
await t.step("Get correct state", reading.getCorrectState);
await t.step("Get false state", reading.getFalseState);
});
// main_test.ts
import { createHandler, ServeHandlerInfo } from "$fresh/server.ts";
import manifest from "../fresh.gen.ts";
import config from "../fresh.config.ts";
import * as listening from "./listening.ts";
import * as reading from "./reading.ts";

export const CONNECTION: ServeHandlerInfo = {
remoteAddr: { hostname: "localhost", port: 8000, transport: "tcp" },
};
export const handler = await createHandler(manifest, config);

Deno.test("Feature: Listening Pinyin", async (t) => {
await t.step("Get the question", listening.getQuestion);
await t.step("Post the answer", listening.postAnswer);
await t.step("Get the correct state", listening.getCorrectState);
await t.step("Get the false state", listening.getFalseState);
});

Deno.test("Feature: Reading Hanzi", async (t) => {
await t.step("Render creation form", reading.renderCreationForm);
await t.step("Start a quiz", reading.startQuiz);
await t.step("Post the answer", reading.postAnswer);
await t.step("Get correct state", reading.getCorrectState);
await t.step("Get false state", reading.getFalseState);
});
Deno AI Helper
Deno AI Helper•7mo ago
To ensure that your multiple test scripts are detected and managed properly in the Test Explorer, you should follow these guidelines based on the documentation: 1. File Inclusion/Exclusion: Make sure that your test files are included in the set of files that the Test Explorer recognizes. This can be configured using the deno.json configuration file, specifically with the test.include and test.exclude fields. By setting these fields, you can control which files are considered for testing and which are ignored. 2. Unique Test Step Names: If you are using test steps, ensure that each test step has a unique name. There were issues with the Test Explorer freezing or not updating correctly when test steps with the same name were not registered uniquely, but this has been fixed in the latest release. 3. Running Tests: When running tests from the Test Explorer, it will no longer evaluate modules that don't contain any tests, and modules without tests will not be shown in the Test Explorer. This helps to keep the Test Explorer clean and focused on actual test files. 4. Test Execution: If you have tests with the { only: true } option set, running a single test via code lens will now behave as expected and properly ignore other tests. This means you can focus on running a specific test without interference from others marked as only. 5. File Filtering: The Test Explorer and the Run test code lens now filter files based on the exclude, test.exclude, and test.include fields in deno.json. This helps in managing which test scripts are detected and displayed. By following these guidelines, you should be able to manage your test scripts effectively and ensure that they are properly detected and displayed in the Test Explorer. 🦕