-
Notifications
You must be signed in to change notification settings - Fork 60
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
Feature: Update the existing test cases and include new test cases for every component #174
Comments
cc: @RayMathew, @Buzzpy Would like to have your opinion on this feature |
|
Thanks for your opinion. Yes, I mean test files |
Kindly assign to me if this is workable |
Added PR-175 |
I'd like some guidance on writing the test file for the Do you have any ideas? Below is the skeleton code for the test script import { experimental_AstroContainer as AstroContainer } from "astro/container"
import { expect, test } from "vitest"
import Modal from "./Modal.astro"
describe("test Modal component", () => {
let container: AstroContainer
beforeEach(async () => {
// instantiate Astro container api
container = await AstroContainer.create()
})
test("user click one of the terms card and the explanation modal is explained", async () => {
// To-do: mock function for mocking modal.ts
})
}) |
Take what I'm saying with caution, since I haven't looked at Astro testing so far and the best practices. Going through the code, it doesn't make sense to me to test Modal.astro, since there's almost nothing in it. It should be the reverse. Test modal.ts, and mock the contents of Modal.astro. Like this:
I realise that ideally we should be testing .astro files since this is an Astro project. But since the migration hasn't been done you have a choice. 1) Migrate the code from modal.ts to Modal.astro and then test. 2) Test modal.ts in its current state and leave migration for a future task. |
Thanks, @RayMathew for the advice. I'll update the test file right away. For the moment, I agree that 2.) would be a better option for the moment. |
Hi @Buzzpy, PR-175 is updated with test modal.ts for the functional test. Notice that only positive assertion tests are included for the moment. Kindly comment if negative assertion tests are also required. Otherwise, the PR should be ready to merge. Update: any comments? @Buzzpy |
Description:
I will update some existing test cases for the components in the project and include new unit test scripts for other components. Below is a summary of the implementation covered in this issue:
Expected outcome
The text was updated successfully, but these errors were encountered: