diff --git a/jest.config.js b/jest.config.js index 12004699..6dcc4105 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,5 +4,5 @@ module.exports = { clearMocks: true, coverageProvider: 'v8', setupFilesAfterEnv: ['./jest.setup.pg-mock.js', './jest.setup.redis-mock.js', './jest.setup.fetch-mock.js'], - testMatch: ['/src/**/__tests__/**/*.test.ts'], + testMatch: ['/tests/**/*.test.ts'], } diff --git a/src/__tests__/helpers/plugins.ts b/tests/helpers/plugins.ts similarity index 99% rename from src/__tests__/helpers/plugins.ts rename to tests/helpers/plugins.ts index c053a47f..0c3dde2b 100644 --- a/src/__tests__/helpers/plugins.ts +++ b/tests/helpers/plugins.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginAttachmentDB, PluginConfig } from '../../types' +import { Plugin, PluginAttachmentDB, PluginConfig } from '../../src/types' import fs from 'fs' import path from 'path' import os from 'os' diff --git a/src/__tests__/helpers/sqlMock.ts b/tests/helpers/sqlMock.ts similarity index 95% rename from src/__tests__/helpers/sqlMock.ts rename to tests/helpers/sqlMock.ts index b6e820cb..42140942 100644 --- a/src/__tests__/helpers/sqlMock.ts +++ b/tests/helpers/sqlMock.ts @@ -1,4 +1,4 @@ -import * as s from '../../sql' +import * as s from '../../src/sql' // mock functions that get data from postgres and give them the right types type UnPromisify = F extends (...args: infer A) => Promise ? (...args: A) => T : never diff --git a/src/worker/__tests__/piscina.test.ts b/tests/piscina.test.ts similarity index 94% rename from src/worker/__tests__/piscina.test.ts rename to tests/piscina.test.ts index 4e6bb884..074d10c5 100644 --- a/src/worker/__tests__/piscina.test.ts +++ b/tests/piscina.test.ts @@ -1,11 +1,11 @@ -import { defaultConfig } from '../../server' -import { makePiscina } from '../piscina' +import { defaultConfig } from '../src/server' +import { makePiscina } from '../src/worker/piscina' import { PluginEvent } from 'posthog-plugins/src/types' import { performance } from 'perf_hooks' -import { mockJestWithIndex } from '../../__tests__/helpers/plugins' +import { mockJestWithIndex } from './helpers/plugins' import * as os from 'os' -jest.mock('../../sql') +jest.mock('../src/sql') jest.setTimeout(300000) // 300 sec timeout function processOneEvent(processEvent: (event: PluginEvent) => Promise): Promise { diff --git a/src/__tests__/plugins.test.ts b/tests/plugins.test.ts similarity index 98% rename from src/__tests__/plugins.test.ts rename to tests/plugins.test.ts index 0c0ed7f3..0d7dd617 100644 --- a/src/__tests__/plugins.test.ts +++ b/tests/plugins.test.ts @@ -1,6 +1,6 @@ -import { runPlugins, setupPlugins } from '../plugins' -import { createServer } from '../server' -import { PluginsServer } from '../types' +import { runPlugins, setupPlugins } from '../src/plugins' +import { createServer } from '../src/server' +import { PluginsServer } from '../src/types' import { PluginEvent } from 'posthog-plugins/src/types' import { mockPluginTempFolder, @@ -10,7 +10,7 @@ import { pluginConfig39, } from './helpers/plugins' import { getPluginAttachmentRows, getPluginConfigRows, getPluginRows, setError } from './helpers/sqlMock' -jest.mock('../sql') +jest.mock('../src/sql') let mockServer: PluginsServer beforeEach(async () => { diff --git a/src/worker/__tests__/queue.test.ts b/tests/queue.test.ts similarity index 95% rename from src/worker/__tests__/queue.test.ts rename to tests/queue.test.ts index 59f5b3d5..a91c49fe 100644 --- a/src/worker/__tests__/queue.test.ts +++ b/tests/queue.test.ts @@ -1,8 +1,8 @@ -import { startQueue } from '../queue' -import { createServer, defaultConfig } from '../../server' -import { PluginsServer } from '../../types' -import Client from '../../celery/client' -import { runPlugins } from '../../plugins' +import { startQueue } from '../src/worker/queue' +import { createServer, defaultConfig } from '../src/server' +import { PluginsServer } from '../src/types' +import Client from '../src/celery/client' +import { runPlugins } from '../src/plugins' function advanceOneTick() { return new Promise((resolve) => process.nextTick(resolve)) diff --git a/src/__tests__/sql.test.ts b/tests/sql.test.ts similarity index 96% rename from src/__tests__/sql.test.ts rename to tests/sql.test.ts index 478bdcd0..c11766d3 100644 --- a/src/__tests__/sql.test.ts +++ b/tests/sql.test.ts @@ -1,6 +1,6 @@ -import { getPluginAttachmentRows, getPluginConfigRows, getPluginRows, setError } from '../sql' -import { Plugin, PluginAttachmentDB, PluginConfig, PluginError, PluginsServer } from '../types' -import { createServer } from '../server' +import { getPluginAttachmentRows, getPluginConfigRows, getPluginRows, setError } from '../src/sql' +import { Plugin, PluginAttachmentDB, PluginConfig, PluginError, PluginsServer } from '../src/types' +import { createServer } from '../src/server' let mockServer: PluginsServer beforeEach(async () => { diff --git a/src/__tests__/utils.test.ts b/tests/utils.test.ts similarity index 99% rename from src/__tests__/utils.test.ts rename to tests/utils.test.ts index 2f6c41c4..871c8098 100644 --- a/src/__tests__/utils.test.ts +++ b/tests/utils.test.ts @@ -1,4 +1,4 @@ -import { getFileFromTGZ, getFileFromZip, getFileFromArchive, bufferToStream } from '../utils' +import { getFileFromTGZ, getFileFromZip, getFileFromArchive, bufferToStream } from '../src/utils' // .zip in Base64: github repo posthog/helloworldplugin const zip = diff --git a/src/__tests__/vm.test.ts b/tests/vm.test.ts similarity index 98% rename from src/__tests__/vm.test.ts rename to tests/vm.test.ts index 34d57041..168b84b3 100644 --- a/src/__tests__/vm.test.ts +++ b/tests/vm.test.ts @@ -1,7 +1,7 @@ -import { createPluginConfigVM, prepareForRun } from '../vm' -import { PluginConfig, PluginsServer, Plugin } from '../types' +import { createPluginConfigVM, prepareForRun } from '../src/vm' +import { PluginConfig, PluginsServer, Plugin } from '../src/types' import { PluginEvent } from 'posthog-plugins' -import { createServer, defaultConfig } from '../server' +import { createServer, defaultConfig } from '../src/server' import * as fetch from 'node-fetch' const defaultEvent = {