From fe708f04eeb323e86b76374972bb07fc791ddfff Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 1 Aug 2024 17:32:24 +0200 Subject: [PATCH] chore: explicitly import from vitests (#2479) --- server/api.e2e.test.ts | 1 + server/database/integration.test.ts | 1 + server/documents/integration.test.ts | 1 + server/documents/resolvers.spec.ts | 1 + server/documents/user.document.service.spec.ts | 1 + server/e2e.test.ts | 1 + server/getLatestRelease.e2e.test.ts | 1 + server/journals/journal.service.spec.ts | 1 + server/user/e2e.test.ts | 2 +- server/user/integration.test.ts | 1 + server/user/resolvers.spec.ts | 1 + server/utils/crypto.spec.ts | 1 + server/utils/validation.spec.ts | 1 + test/global.setup.ts | 2 +- vitest.config.ts | 4 ---- 15 files changed, 14 insertions(+), 6 deletions(-) diff --git a/server/api.e2e.test.ts b/server/api.e2e.test.ts index 69a00ada6..693aa689f 100644 --- a/server/api.e2e.test.ts +++ b/server/api.e2e.test.ts @@ -1,4 +1,5 @@ import { gql as gqlNotVerified } from 'graphql-tag' +import { describe, expect, it } from 'vitest' import { api, root } from '~/test/api-e2e/supertest' describe('invalid query', () => { diff --git a/server/database/integration.test.ts b/server/database/integration.test.ts index dbb1806c4..37d4e5a91 100644 --- a/server/database/integration.test.ts +++ b/server/database/integration.test.ts @@ -1,3 +1,4 @@ +import { afterAll, beforeEach, describe, expect, it } from 'vitest' import * as prisma from '~/server/database/util' import { resolve } from '../tsyringe' diff --git a/server/documents/integration.test.ts b/server/documents/integration.test.ts index 02830d05a..7145bc3f5 100644 --- a/server/documents/integration.test.ts +++ b/server/documents/integration.test.ts @@ -1,4 +1,5 @@ import { gql } from 'graphql-tag' +import { afterAll, beforeEach, describe, expect, it } from 'vitest' import * as prisma from '~/server/database/util' import { createAuthenticatedClient } from '~/test/apollo.server' import { removeIds } from '~/test/util' diff --git a/server/documents/resolvers.spec.ts b/server/documents/resolvers.spec.ts index eb3fed96a..10b5e587d 100644 --- a/server/documents/resolvers.spec.ts +++ b/server/documents/resolvers.spec.ts @@ -1,3 +1,4 @@ +import { beforeEach, describe, expect, it } from 'vitest' import { mock, mockReset } from 'vitest-mock-extended' import { createUnauthenticatedContext } from '~/test/context.helper' import { register, resolve } from '../tsyringe' diff --git a/server/documents/user.document.service.spec.ts b/server/documents/user.document.service.spec.ts index 1528e9133..477593f5d 100644 --- a/server/documents/user.document.service.spec.ts +++ b/server/documents/user.document.service.spec.ts @@ -1,4 +1,5 @@ import type { PrismaClient } from '@prisma/client' +import { beforeEach, describe, expect, it } from 'vitest' import { mockDeep, mockReset } from 'vitest-mock-extended' import { register, resolve } from '../tsyringe' import type { UserDocument } from './user.document.service' diff --git a/server/e2e.test.ts b/server/e2e.test.ts index 592dba864..2d33f891b 100644 --- a/server/e2e.test.ts +++ b/server/e2e.test.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from 'vitest' import { root } from '~/test/api-e2e/supertest' describe('index page', () => { diff --git a/server/getLatestRelease.e2e.test.ts b/server/getLatestRelease.e2e.test.ts index da829db3b..5f5c50837 100644 --- a/server/getLatestRelease.e2e.test.ts +++ b/server/getLatestRelease.e2e.test.ts @@ -1,4 +1,5 @@ import type { InternalApi } from 'nitropack' +import { expect, test } from 'vitest' import { root } from '~/test/api-e2e/supertest' type GetLatestReleaseResponse = InternalApi['/api/getLatestRelease']['default'] diff --git a/server/journals/journal.service.spec.ts b/server/journals/journal.service.spec.ts index 567bd8c69..362251fa0 100644 --- a/server/journals/journal.service.spec.ts +++ b/server/journals/journal.service.spec.ts @@ -1,4 +1,5 @@ import type { Journal, PrismaClient } from '@prisma/client' +import { beforeEach, describe, expect, it } from 'vitest' import { mockDeep, mockReset } from 'vitest-mock-extended' import { register, resolve } from '../tsyringe' diff --git a/server/user/e2e.test.ts b/server/user/e2e.test.ts index 7f01bf787..73091b409 100644 --- a/server/user/e2e.test.ts +++ b/server/user/e2e.test.ts @@ -1,5 +1,5 @@ import { gql } from 'graphql-tag' -import { test } from 'vitest' +import { describe, expect, it, test } from 'vitest' import { api, login } from '~/test/api-e2e/supertest' import { getEmail, getTemporaryEmail } from '~/test/email' diff --git a/server/user/integration.test.ts b/server/user/integration.test.ts index d9001cba2..eec24f99d 100644 --- a/server/user/integration.test.ts +++ b/server/user/integration.test.ts @@ -1,4 +1,5 @@ import { gql } from 'graphql-tag' +import { afterAll, beforeEach, describe, expect, it } from 'vitest' import * as prisma from '~/server/database/util' import { createAuthenticatedClient } from '~/test/apollo.server' diff --git a/server/user/resolvers.spec.ts b/server/user/resolvers.spec.ts index edd825837..573b3d2ed 100644 --- a/server/user/resolvers.spec.ts +++ b/server/user/resolvers.spec.ts @@ -1,3 +1,4 @@ +import { beforeEach, describe, expect, it } from 'vitest' import { mock, mockReset } from 'vitest-mock-extended' import { createUnauthenticatedContext } from '~/test/context.helper' import { register, resolve } from '../tsyringe' diff --git a/server/utils/crypto.spec.ts b/server/utils/crypto.spec.ts index db279065e..f1737ba77 100644 --- a/server/utils/crypto.spec.ts +++ b/server/utils/crypto.spec.ts @@ -1,3 +1,4 @@ +import { describe, expect, it } from 'vitest' import { hash, verifyHash } from './crypto' describe('hash', () => { diff --git a/server/utils/validation.spec.ts b/server/utils/validation.spec.ts index 11a42d9f3..7591776bb 100644 --- a/server/utils/validation.spec.ts +++ b/server/utils/validation.spec.ts @@ -1,4 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ +import { describe, expect, it } from 'vitest' import { z } from 'zod' import { validateInput, validation } from './validation' diff --git a/test/global.setup.ts b/test/global.setup.ts index ee4abe7ec..42ae8adfd 100644 --- a/test/global.setup.ts +++ b/test/global.setup.ts @@ -3,7 +3,7 @@ import prisma from '@prisma/client' import 'dotenv/config' import 'json-bigint-patch' import 'reflect-metadata' -import { beforeAll } from 'vitest' +import { beforeAll, expect } from 'vitest' import { constructConfig } from '~/config' import { register } from '~/server/tsyringe' import { registerClasses } from '~/server/tsyringe.config' diff --git a/vitest.config.ts b/vitest.config.ts index 8a5c87181..9e1100485 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -11,10 +11,6 @@ export default defineVitestConfig({ }, }, test: { - // Provide global API - // https://vitest.dev/config/#globals - globals: true, - // Run before each test file // https://vitest.dev/config/#setupfiles setupFiles: ['test/global.setup.ts'],