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

refactor(tests): migrate from tap to node test runners #107

Merged
merged 21 commits into from
Nov 13, 2023

Conversation

mateonunez
Copy link
Contributor

@mateonunez mateonunez commented Nov 10, 2023

This PR aims to resolve #98 by migrating the whole codebase of tests that runs server side using the Node Test Runners

  • test/base.test.js
  • test/cache.test.js
  • test/clear.test.js
  • test/stale.test.js
  • test/storage-base.test.js
  • test/storage-memory.test.js
  • test/storage-redis.test.js
  • test/transformer.test.js
  • test/ttl.test.js
  • test/utils.test.js

I used tspl where required by previous tests. Otherwise I kept the default Node assertions.

We need to figure out possibly whether to normalize all assertions under tspl or proceed to use only if we are going to ensure assertion count.

Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
@mateonunez mateonunez marked this pull request as ready for review November 10, 2023 16:23
@mateonunez
Copy link
Contributor Author

mateonunez commented Nov 10, 2023

The CI got stuck, this is probably the related issue: nodejs/node#49344.

In this PR I have added c8 in such a way as to have view of the current full coverage. In the past, to run the pipeline, I had to restart it: mateonunez/fastify-orama#163.

We can remove c8 but then we would lose the coverage report.

Thoughts on this?

cc @mcollina @simone-sanfratello

@mcollina
Copy link
Owner

Seems redis getting stuck, can you take a closer look?

Signed-off-by: mateonunez <mateonunez95@gmail.com>
@mateonunez
Copy link
Contributor Author

Green light! ✅

Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

package.json Outdated
@@ -5,7 +5,7 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "standard | snazzy && tap test/*test.js && tsd",
"test": "standard | snazzy && c8 --100 node --test test/*.js && tsd",
Copy link
Collaborator

Choose a reason for hiding this comment

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

it was test/*test.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch!

@@ -18,16 +20,16 @@ const dummyStorage = {
}

let redisClient
before(async (t) => {
beforeEach(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

before is still before, not beforeEach

redisClient = new Redis()
})

teardown(async (t) => {
afterEach(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

teardown is after

await redisClient.flushall()
})
describe('storage redis', async () => {
beforeEach(async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

before instead of beforeEach

const Redis = require('ioredis')

const createStorage = require('../src/storage')
const { Cache } = require('../')

let redisClient
before(async (t) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please keep before and after

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in the suite

Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
Signed-off-by: mateonunez <mateonunez95@gmail.com>
@simone-sanfratello
Copy link
Collaborator

well done :)

@simone-sanfratello simone-sanfratello merged commit aa45cbd into mcollina:main Nov 13, 2023
54 checks passed
@mateonunez mateonunez deleted the refactor/remove-tap branch November 13, 2023 13:11
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.

migrate test to node:test core lib
3 participants