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

docs(testing): improve the docs of @std/testing #5033

Merged
merged 20 commits into from
Jun 17, 2024

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Jun 12, 2024

part of #3764

@kt3k kt3k mentioned this pull request Jun 12, 2024
38 tasks
@kt3k kt3k marked this pull request as ready for review June 13, 2024 12:18
Copy link

codecov bot commented Jun 13, 2024

Codecov Report

Attention: Patch coverage is 72.63158% with 26 lines in your changes missing coverage. Please review.

Project coverage is 92.12%. Comparing base (0ad578f) to head (dba7899).
Report is 7 commits behind head on main.

Files Patch % Lines
testing/bdd.ts 52.08% 23 Missing ⚠️
testing/time.ts 86.36% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5033      +/-   ##
==========================================
+ Coverage   92.10%   92.12%   +0.01%     
==========================================
  Files         487      487              
  Lines       38798    38865      +67     
  Branches     5432     5435       +3     
==========================================
+ Hits        35736    35805      +69     
+ Misses       3006     3005       -1     
+ Partials       56       55       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kt3k kt3k requested a review from iuioiua June 13, 2024 12:35
@@ -67,7 +72,8 @@ const ENTRY_POINTS = [
] as const;

const TS_SNIPPET = /```ts[\s\S]*?```/g;
const ASSERTION_IMPORT = /import \{.*\} from "@std\/assert(?:\/.*)?";/gm;
const ASSERTION_IMPORT =
/from "@std\/(assert(\/[a-z-]+)?|testing\/(mock|snapshot|types))"/g;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed import \{.*\} part as this doesn't work if there are line breaks between import and from.

Also added testing\/(mock|snapshot|types) part as these files also include assertion functions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having assertions spread across multiple packages is confusing. What if we moved assertions (only) to @std/assert? WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes @std/assert a huge package. In the current layout, assertions are organized by the category (mock / snapshot / types). This makes more sense to me.

Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass review

testing/README.md Outdated Show resolved Hide resolved
@@ -62,6 +64,7 @@ const optionalTestStepDefinitionKeys: (keyof Deno.TestStepDefinition)[] = [
* A group of tests.
*/
export interface TestSuite<T> {
/** The symbol */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem informative.

testing/types.ts Outdated Show resolved Hide resolved
testing/types.ts Outdated
Comment on lines 20 to 24
* @typeParam T The expected type (`true` or `false`)
* @param expectTrue - True if the passed in type argument resolved to true.
*/
export function assertType<T extends true | false>(_expectTrue: T) {
}
export function assertType<T extends true | false>(
// deno-lint-ignore no-unused-vars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @typeParam T The expected type (`true` or `false`)
* @param expectTrue - True if the passed in type argument resolved to true.
*/
export function assertType<T extends true | false>(_expectTrue: T) {
}
export function assertType<T extends true | false>(
// deno-lint-ignore no-unused-vars
* @typeParam T The expected type
* @param expectTrue - True if the passed in type argument resolved to true.
*/
export function assertType<T extends boolean>(
// deno-lint-ignore no-unused-vars

testing/types.ts Show resolved Hide resolved
testing/bdd.ts Outdated
@@ -816,6 +1023,7 @@ describe.only = function describeOnly<T>(
});
};

/** Ignore the test suite */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include targeted examples for these methods?

@@ -67,7 +72,8 @@ const ENTRY_POINTS = [
] as const;

const TS_SNIPPET = /```ts[\s\S]*?```/g;
const ASSERTION_IMPORT = /import \{.*\} from "@std\/assert(?:\/.*)?";/gm;
const ASSERTION_IMPORT =
/from "@std\/(assert(\/[a-z-]+)?|testing\/(mock|snapshot|types))"/g;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having assertions spread across multiple packages is confusing. What if we moved assertions (only) to @std/assert? WDYT?

testing/snapshot.ts Outdated Show resolved Hide resolved
@iuioiua iuioiua changed the title docs(testing): improve the docs of @std/testing docs(testing): improve the docs of @std/testing Jun 16, 2024
Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Good to see this done.

testing/time.ts Outdated Show resolved Hide resolved
testing/time.ts Outdated Show resolved Hide resolved
testing/time.ts Outdated Show resolved Hide resolved
testing/time.ts Outdated Show resolved Hide resolved
testing/time.ts Outdated Show resolved Hide resolved
* }, Error)
* ```
* @param value The value to set
*/
set start(value: number) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this setter in a follow-up PR.

@kt3k kt3k merged commit 635e062 into denoland:main Jun 17, 2024
12 checks passed
@kt3k kt3k deleted the document-testing branch June 17, 2024 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants