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

add JSDoc to Vitest code #5191

Closed
4 tasks done
yukulele opened this issue Feb 13, 2024 · 3 comments · Fixed by #6822
Closed
4 tasks done

add JSDoc to Vitest code #5191

yukulele opened this issue Feb 13, 2024 · 3 comments · Fixed by #6822
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@yukulele
Copy link

yukulele commented Feb 13, 2024

Clear and concise description of the problem

Vitest functions have little or no documentation in the code, making them difficult to use and adopt.

This is what the editor shows me:
Screenshot_20240213_110246

and this is what I hope to see:
Screenshot_20240213_105833

Suggested solution

add JSDoc to Vitest code

Alternative

I have to go to the documentation every time I'm not sure how to use a function :/

Additional context

No response

Validations

@sheremet-va sheremet-va added documentation Improvements or additions to documentation good first issue Good for newcomers labels Feb 13, 2024
@yukulele yukulele changed the title add jsdoc add JSDoc to code Feb 13, 2024
@yukulele yukulele changed the title add JSDoc to code add JSDoc to Vitest code Feb 13, 2024
@geeksilva97
Copy link

geeksilva97 commented Jun 18, 2024

hey folks, I'd like to take a look on it to get familiarized with the project. would you guys have any clue? I've been searching for where jsdocs are added in expect packages but I could not find yet.

@hi-ogawa
Copy link
Contributor

You can add jsdoc to the type definition here

export interface JestAssertion<T = any> extends jest.Matchers<void, T> {
// Jest compact
toEqual: <E>(expected: E) => void
toStrictEqual: <E>(expected: E) => void
toBe: <E>(expected: E) => void
toMatch: (expected: string | RegExp) => void
toMatchObject: <E extends {} | any[]>(expected: E) => void
toContain: <E>(item: E) => void
toContainEqual: <E>(item: E) => void
toBeTruthy: () => void
toBeFalsy: () => void
toBeGreaterThan: (num: number | bigint) => void
toBeGreaterThanOrEqual: (num: number | bigint) => void
toBeLessThan: (num: number | bigint) => void
toBeLessThanOrEqual: (num: number | bigint) => void
toBeNaN: () => void
toBeUndefined: () => void
toBeNull: () => void
toBeDefined: () => void
toBeInstanceOf: <E>(expected: E) => void
toBeCalledTimes: (times: number) => void
toHaveLength: (length: number) => void
toHaveProperty: <E>(
property: string | (string | number)[],
value?: E
) => void
toBeCloseTo: (number: number, numDigits?: number) => void
toHaveBeenCalledTimes: (times: number) => void
toHaveBeenCalled: () => void
toBeCalled: () => void
toHaveBeenCalledWith: <E extends any[]>(...args: E) => void
toBeCalledWith: <E extends any[]>(...args: E) => void
toHaveBeenNthCalledWith: <E extends any[]>(n: number, ...args: E) => void
nthCalledWith: <E extends any[]>(nthCall: number, ...args: E) => void
toHaveBeenLastCalledWith: <E extends any[]>(...args: E) => void
lastCalledWith: <E extends any[]>(...args: E) => void
toThrow: (expected?: string | Constructable | RegExp | Error) => void
toThrowError: (expected?: string | Constructable | RegExp | Error) => void
toReturn: () => void
toHaveReturned: () => void
toReturnTimes: (times: number) => void
toHaveReturnedTimes: (times: number) => void
toReturnWith: <E>(value: E) => void
toHaveReturnedWith: <E>(value: E) => void
toHaveLastReturnedWith: <E>(value: E) => void
lastReturnedWith: <E>(value: E) => void
toHaveNthReturnedWith: <E>(nthCall: number, value: E) => void
nthReturnedWith: <E>(nthCall: number, value: E) => void
}

For example,

  /**
   * write something...
   * @example
   *   expect("xxx").toEqual("xxx") // OK
   */
  toEqual: <E>(expected: E) => void

image

@geeksilva97
Copy link

Thanks a lot man!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants