Skip to content

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

Merged
kt3k merged 20 commits into
denoland:mainfrom
kt3k:document-testing
Jun 17, 2024
Merged

kt3k merged 20 commits into
denoland:mainfrom
kt3k:document-testing

Conversation

@kt3k

@kt3k kt3k commented Jun 12, 2024 •

Copy link
Copy Markdown
Contributor

part of #3764

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

codecov Bot commented Jun 13, 2024 •

Copy link
Copy Markdown

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
Comment thread _tools/check_docs.ts Resolved
Comment thread _tools/check_docs.ts
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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.

@iuioiua iuioiua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

First pass review

Comment thread testing/README.md Resolved
Comment thread testing/_test_suite.ts Outdated
* A group of tests.
*/
export interface TestSuite<T> {
/** The symbol */

Copy link
Copy Markdown
Contributor

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.

Comment thread testing/types.ts Resolved
Comment thread testing/types.ts
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
Copy Markdown
Contributor

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

Comment thread testing/types.ts Resolved
Comment thread testing/bdd.ts Outdated
});
};

/** Ignore the test suite */

Copy link
Copy Markdown
Contributor

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?

Comment thread _tools/check_docs.ts
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
Copy Markdown
Contributor

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?

Comment thread testing/snapshot.ts 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

@iuioiua iuioiua left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread testing/time.ts Resolved
Comment thread testing/time.ts Resolved
Comment thread testing/time.ts Resolved
Comment thread testing/time.ts Resolved
Comment thread testing/time.ts Resolved
Comment thread testing/time.ts
* ```
* @param value The value to set
*/
set start(value: number) {

Copy link
Copy Markdown
Contributor

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
@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