From 482b5b0e8a662e9ba46f3b5faf649d5db508aec0 Mon Sep 17 00:00:00 2001 From: Isaac Hunter Date: Wed, 6 Nov 2024 14:20:16 -0500 Subject: [PATCH] fix issue with jest module import --- docker-compose.network.yml | 2 +- src/jukebox/tests/jukebox.controller.spec.ts | 3 +-- src/jukebox/tests/jukebox.gateway.spec.ts | 2 +- src/jukebox/tests/jukebox.service.spec.ts | 2 +- src/jukebox/track-queue/tests/track-queue.service.spec.ts | 2 +- src/spotify/tests/spotify.controller.spec.ts | 2 +- src/spotify/tests/spotify.service.spec.ts | 2 +- src/utils/index.ts | 4 +++- src/utils/testing/mocking.ts | 3 ++- 9 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docker-compose.network.yml b/docker-compose.network.yml index 7b2386d..a521b9a 100644 --- a/docker-compose.network.yml +++ b/docker-compose.network.yml @@ -28,7 +28,7 @@ services: depends_on: - postgres - pgadmin - - kafka + # - kafka - redis volumes: - ./src:/app/src diff --git a/src/jukebox/tests/jukebox.controller.spec.ts b/src/jukebox/tests/jukebox.controller.spec.ts index 2f7996c..de88334 100644 --- a/src/jukebox/tests/jukebox.controller.spec.ts +++ b/src/jukebox/tests/jukebox.controller.spec.ts @@ -6,9 +6,8 @@ import { NetworkModule } from 'src/network/network.module' import { SpotifyAccount } from 'src/spotify/entities/spotify-account.entity' import { SpotifyAuthService } from 'src/spotify/spotify-auth.service' import { SpotifyService } from 'src/spotify/spotify.service' -import { mockCache, mockRepo, type MockType } from 'src/utils' import { AxiosProvider } from 'src/utils/providers/axios.provider' -import type { Repository } from 'typeorm' +import { mockCache, mockRepo } from 'src/utils/testing' import { Jukebox, JukeboxLinkAssignment } from '../entities/jukebox.entity' import { JukeboxController } from '../jukebox.controller' import { JukeboxService } from '../jukebox.service' diff --git a/src/jukebox/tests/jukebox.gateway.spec.ts b/src/jukebox/tests/jukebox.gateway.spec.ts index 8850eca..b047e73 100644 --- a/src/jukebox/tests/jukebox.gateway.spec.ts +++ b/src/jukebox/tests/jukebox.gateway.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing' import { getRepositoryToken } from '@nestjs/typeorm' import { AppGateway } from 'src/app.gateway' import { SpotifyService } from 'src/spotify/spotify.service' -import { mockCache, mockRepo } from 'src/utils' +import { mockCache, mockRepo } from 'src/utils/testing' import { Jukebox, JukeboxLinkAssignment } from '../entities/jukebox.entity' import { JukeboxGateway } from '../jukebox.gateway' import { JukeboxService } from '../jukebox.service' diff --git a/src/jukebox/tests/jukebox.service.spec.ts b/src/jukebox/tests/jukebox.service.spec.ts index eb77ff8..cc29316 100644 --- a/src/jukebox/tests/jukebox.service.spec.ts +++ b/src/jukebox/tests/jukebox.service.spec.ts @@ -2,7 +2,7 @@ import type { TestingModule } from '@nestjs/testing' import { Test } from '@nestjs/testing' import { getRepositoryToken } from '@nestjs/typeorm' import { SpotifyAccount } from 'src/spotify/entities/spotify-account.entity' -import type { MockType } from 'src/utils' +import type { MockType } from 'src/utils/testing' import type { Repository } from 'typeorm' import { Jukebox, JukeboxLinkAssignment } from '../entities/jukebox.entity' import { JukeboxService } from '../jukebox.service' diff --git a/src/jukebox/track-queue/tests/track-queue.service.spec.ts b/src/jukebox/track-queue/tests/track-queue.service.spec.ts index 7d9b736..5ae6118 100644 --- a/src/jukebox/track-queue/tests/track-queue.service.spec.ts +++ b/src/jukebox/track-queue/tests/track-queue.service.spec.ts @@ -1,6 +1,6 @@ import type { TestingModule } from '@nestjs/testing' import { Test } from '@nestjs/testing' -import { mockCache } from 'src/utils' +import { mockCache } from 'src/utils/testing' import { TrackQueueService } from '../track-queue.service' describe('TrackQueueService', () => { diff --git a/src/spotify/tests/spotify.controller.spec.ts b/src/spotify/tests/spotify.controller.spec.ts index 4e2f255..e9ef9cf 100644 --- a/src/spotify/tests/spotify.controller.spec.ts +++ b/src/spotify/tests/spotify.controller.spec.ts @@ -3,7 +3,7 @@ import { Test } from '@nestjs/testing' import { getRepositoryToken } from '@nestjs/typeorm' import Axios from 'axios' import { NetworkModule } from 'src/network/network.module' -import type { MockType } from 'src/utils' +import type { MockType } from 'src/utils/testing' import type { Repository } from 'typeorm' import { SpotifyAccount } from '../entities/spotify-account.entity' import { SpotifyAuthService } from '../spotify-auth.service' diff --git a/src/spotify/tests/spotify.service.spec.ts b/src/spotify/tests/spotify.service.spec.ts index 11dcee4..92f6937 100644 --- a/src/spotify/tests/spotify.service.spec.ts +++ b/src/spotify/tests/spotify.service.spec.ts @@ -4,7 +4,7 @@ import { Test } from '@nestjs/testing' import { getRepositoryToken } from '@nestjs/typeorm' import Axios from 'axios' import { Model } from 'mongoose' -import type { MockType } from 'src/utils' +import type { MockType } from 'src/utils/testing' import type { Repository } from 'typeorm' import { SpotifyAccount } from '../entities/spotify-account.entity' import { SpotifyAuthService } from '../spotify-auth.service' diff --git a/src/utils/index.ts b/src/utils/index.ts index e3b1173..c55ae8f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,4 +2,6 @@ export * from './filters' export * from './helpers' export * from './interceptors' export * from './mock' -export * from './testing' + +// Do not include testing in export, auto imports testing modules +// export * from './testing' diff --git a/src/utils/testing/mocking.ts b/src/utils/testing/mocking.ts index 5b8ce28..96997fd 100644 --- a/src/utils/testing/mocking.ts +++ b/src/utils/testing/mocking.ts @@ -1,8 +1,9 @@ +import { jest } from '@jest/globals' import { CACHE_MANAGER } from '@nestjs/cache-manager' import { Repository } from 'typeorm' export type MockType = { - [P in keyof T]?: jest.Mock + [P in keyof T]?: jest.Mock } export const mockCache = {