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

Use @ava/typescript for testing #113

Merged
merged 4 commits into from
Mar 13, 2020
Merged

Use @ava/typescript for testing #113

merged 4 commits into from
Mar 13, 2020

Conversation

tlaundal
Copy link
Contributor

@tlaundal tlaundal commented Mar 12, 2020

This PR moves us away from ts-node and tsconfig-paths in favour of using @ava/typescript for running our .spec.ts tests. This should be a simpler and more robust setup.

Some big changes had to be made along the way

  • Deleted the examples directory. It provides too little value to be worth maintaining. It's function should be fulfilled by our documentation (which is in need of updating)
  • Made all imports relative. There is generally poor support for absolute imports in the tooling around typescript. Doing this also reveals that we should do some work on our folder structure

With this change, you need to run both yarn watch and yarn test:watch in order to have live test running.

It's probably best to review commit by commit.

Tobias Laundal added 3 commits March 12, 2020 14:46
The examples grow stale, and don't provide any real value for testing.
Most of what is covered in the examples would better be covered in the documentation.
Typescript support for absolute imports by using paths and baseUrl is quite lacking,
especially when it comes to support in tooling.
Cleans up the tsconfig files, and makes tsconfig.json be the main configuration,
used for everything besides publish builds.
@tlaundal tlaundal self-assigned this Mar 12, 2020
@tlaundal tlaundal changed the title Ava typescript Use @ava/typescript for testing Mar 12, 2020
Copy link
Contributor

@holographic-principle holographic-principle left a comment

Choose a reason for hiding this comment

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

Looks good, assuming that the imports are all correct.

"@types/sinon": "7.5.2",
"ava": "3.5.0",
"conditional-type-checks": "1.0.5",
"coveralls": "3.0.9",
Copy link
Contributor

Choose a reason for hiding this comment

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

You're still referring to it in the circle config. Don't know if that's an oversight or...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done on purpose. We don't need coveralls in our local repos. npx coveralls will install it as needed in CI.

@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.tspec.ts", "src/**/*.spec.ts"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "esnext",
"target": "es2019",
Copy link
Contributor

Choose a reason for hiding this comment

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

Check that the coverage line numbers are correct with this setting (otherwise lowering the target might work). I seem to remember stumbling upon problems people have had in this regard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did a quick test, and they seem to work as expected.

@tlaundal
Copy link
Contributor Author

tlaundal commented Mar 13, 2020

Sorry for the fixup party. Just trying to make the CI build as smooth as possible. Latest few fixups was to include coveralls in the cache.

EDIT: turns out it might not be possible to cache packages run through npx <package>. It only takes 2.5 seconds so I think it's fine.

paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: yarn install --frozen-lockfile
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might do the trick to avoid this change to do a yarn install --force locally and commit the new lockfile. Also might be worth it to remove all the hats ^ from the package file to avoid "wrong" dependencies.

Sorry for being 🐌 to apply the orb.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I added --frozen-lockfile is that it will fail the build if yarn.lock and package.json do not correspond.

We should remove the hats from all our normal and dev dependencies, but they should stay in the peer dependencies.

Copy link
Collaborator

@andreajl andreajl left a comment

Choose a reason for hiding this comment

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

Screenshot 2020-03-13 at 12 15 49

Nice, looks good. Not sure about the use of two commands for the test watching, but if it's no easy way around 🙈

@tlaundal
Copy link
Contributor Author

See avajs/typescript#3 and avajs/typescript#12 for progress on ava also running the compilation.

I'll go ahead and merge this since there have been no objections :)

@tlaundal
Copy link
Contributor Author

This build failure is a perfect example of why --frozen-lockfile might be useful!
https://app.circleci.com/pipelines/github/ardoq/rxbeach/276/workflows/fcebbd45-99ae-4bce-8a52-f868688c5b58/jobs/273

This commit also removes all version ranges from normal and dev
dependencies and runs yarn install with --frozen-lockfile in CI and
removes coveralls from the dev dependencies in favour of invoking it
through npx.
Copy link
Contributor

@anton164 anton164 left a comment

Choose a reason for hiding this comment

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

👍

@tlaundal tlaundal merged commit b5c26f6 into master Mar 13, 2020
@tlaundal tlaundal deleted the ava-typescript branch March 13, 2020 13:36
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.

None yet

4 participants