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

Allow specifying the test files and typings file manually #74

Merged
merged 23 commits into from
Dec 3, 2020

Conversation

smartclash
Copy link
Contributor

@smartclash smartclash commented Jul 24, 2020

PR 1 of 2. Checkout the 2nd PR here #75

This PR aims to add two more options: testFiles and typingsFile apart from cwd. These are optional and allows developers to manually specify the files which may be somewhere else in the project instead of forcing them to follow a pattern that TSD expects.

This allows us to use TSD in Jest and many other test frameworks so developers can check type definitions without leaving ecosystem.

By merging this, TSD can be used in many ways

Method 1:

Let TSD figure out everything by itself. Uses process.cwd(). Works the way it used to work.

const diagnose = await tsd();

Method 2:

Pass cwd and also the relative path to typingsFile only.

const diagnose = await tsd({
  cwd: path.join(__dirname, '/custom/path'),
  typingsFile: 'someName.d.ts'
});

Method 3:

Pass cwd and also the relative path to testFiles.

const diagnose = await tsd({
  cwd: path.join(__dirname, '/custom/path'),
  testFiles: [
    '/somewhere/app.test.ts',
    '/somewhere/else/math.test.ts'
  ]
});

Method 4:

Pass cwd and pass relative paths to both typingsFile and testFiles.

const diagnose = await tsd({
  cwd: path.join(__dirname, '/custom/path'),
  typingsFile: 'someName.d.ts',
  testFiles: [
    '/somewhere/app.test.ts',
    '/somewhere/else/math.test.ts'
  ]
});

Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

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

LGTM, can you add some unit tests?

@smartclash
Copy link
Contributor Author

Hey, I've added some unit tests. @Ethan-Arrowood. Thanks :)

@SamVerschueren
Copy link
Collaborator

SamVerschueren commented Aug 9, 2020

I like the idea. However, I believe we should go for globbing patterns for the testFiles with globby. It will still accept the array as you provided, but also allow globbing patterns to resolve the files.

Other than that, good idea to add this!

@smartclash
Copy link
Contributor Author

Hey @SamVerschueren, testFiles option now accepts globbing patterns. Uses globby under the hood.

@smartclash smartclash mentioned this pull request Aug 13, 2020
@SimenB
Copy link

SimenB commented Aug 19, 2020

@SamVerschueren @Ethan-Arrowood ping 🙂

Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

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

This looks good. Tests are great too! Good work 😁

@smartclash
Copy link
Contributor Author

Yay, thanks. Also, there's another PR #75 you might want to checkout after this one

@fregante
Copy link

fregante commented Oct 2, 2020

Hoping to see this merged. In a project with a build step, tsd is currently requiring me to keep index.test-d.ts in the dist folder.

fregante referenced this pull request in sindresorhus/memoize Oct 2, 2020
…ts into type_tests to avoid needing to place in dist.
.gitignore Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated
type: `string[]`<br>
default: `['']`

An array of test files with their path
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above (needs to answer what its purpose is) and you're missing a dot at the end.

source/lib/index.ts Outdated Show resolved Hide resolved
source/lib/index.ts Outdated Show resolved Hide resolved
source/lib/index.ts Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@SimenB
Copy link

SimenB commented Oct 29, 2020

Is this good to go now? 🙂 We're currently using a fork, would be lovely to use the mainline 👍

readme.md Outdated Show resolved Hide resolved
smartclash and others added 2 commits December 3, 2020 00:52
@smartclash
Copy link
Contributor Author

I've made the changes. Let me know if it's all good @SamVerschueren :)

@SamVerschueren SamVerschueren merged commit 0e9228a into tsdjs:master Dec 3, 2020
@SamVerschueren
Copy link
Collaborator

Awesome! Thanks for working on this 🙏 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants