Skip to content

Allow specifying the test files and typings file manually#74

Merged
SamVerschueren merged 23 commits into
tsdjs:masterfrom
MLH-Fellowship:relative-paths
Dec 3, 2020
Merged

Allow specifying the test files and typings file manually#74
SamVerschueren merged 23 commits into
tsdjs:masterfrom
MLH-Fellowship:relative-paths

Conversation

@smartclash

@smartclash smartclash commented Jul 24, 2020

Copy link
Copy Markdown

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'
  ]
});

@Ethan-Arrowood Ethan-Arrowood 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.

LGTM, can you add some unit tests?

@smartclash

Copy link
Copy Markdown
Author

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

@SamVerschueren

SamVerschueren commented Aug 9, 2020

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Author

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

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

SimenB commented Aug 19, 2020

Copy link
Copy Markdown

@SamVerschueren @Ethan-Arrowood ping 🙂

@Ethan-Arrowood Ethan-Arrowood 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.

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

@smartclash

Copy link
Copy Markdown
Author

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

@fregante

fregante commented Oct 2, 2020

Copy link
Copy Markdown

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.
Comment thread .gitignore Outdated
Comment thread readme.md Outdated
Comment thread readme.md Outdated
type: `string[]`<br>
default: `['']`

An array of test files with their path

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

Comment thread source/lib/index.ts Outdated
Comment thread source/lib/index.ts Outdated
Comment thread source/lib/index.ts Outdated
Comment thread readme.md Outdated
Comment thread readme.md Outdated
Comment thread readme.md Outdated
@SimenB

SimenB commented Oct 29, 2020

Copy link
Copy Markdown

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

Comment thread readme.md Outdated
Karan Sanjeev and others added 2 commits December 3, 2020 00:52
Co-authored-by: Sam Verschueren <sam.verschueren@gmail.com>
@smartclash

Copy link
Copy Markdown
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
Copy Markdown
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