Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

chore: move package-level tests into the root test folder (#4236)

Martin Adámek3a8fd8ef6c39
diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md
index e6865a524..13a84227b 100644
--- a/.claude/CLAUDE.md
+++ b/.claude/CLAUDE.md
@@ -95,7 +95,7 @@ crawlee # Meta-package re-exporting most @crawlee/* packages
### Test Location
-Most tests are in `/test/` at the repo root; some packages also have their own `packages/*/test/`. E2E tests are in `/test/e2e/`. `tsc-check-tests` only type-checks `/test/`, not `packages/*/test/`.
+All tests are in `/test/` at the repo root, E2E tests in `/test/e2e/`.
## Vitest Notes (vs Jest)
diff --git a/oxlint.config.ts b/oxlint.config.ts
index 9de772b6d..d304d9aaf 100644
--- a/oxlint.config.ts
+++ b/oxlint.config.ts
@@ -122,7 +122,7 @@ export default defineConfig({
},
overrides: [
{
- files: ['test/**/*', 'packages/*/test/**/*'],
+ files: ['test/**/*'],
rules: {
'no-underscore-dangle': 'off',
'typescript/consistent-type-imports': 'off',
diff --git a/packages/basic-crawler/test/tsconfig.json b/packages/basic-crawler/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/basic-crawler/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/browser-pool/test/tsconfig.json b/packages/browser-pool/test/tsconfig.json
deleted file mode 100644
index ea894b0bc..000000000
--- a/packages/browser-pool/test/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "../tsconfig.json",
- "compilerOptions": {
- "noEmit": true,
- "incremental": false,
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/cheerio-crawler/test/tsconfig.json b/packages/cheerio-crawler/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/cheerio-crawler/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/core/test/tsconfig.json b/packages/core/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/core/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/fs-storage/test/tsconfig.json b/packages/fs-storage/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/fs-storage/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/otel/test/tsconfig.json b/packages/otel/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/otel/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/utils/test/tsconfig.json b/packages/utils/test/tsconfig.json
deleted file mode 100644
index eb8cbab58..000000000
--- a/packages/utils/test/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../../tsconfig.json",
- "include": ["**/*", "../../**/*"],
- "compilerOptions": {
- "types": ["vitest/globals"]
- }
-}
diff --git a/packages/basic-crawler/test/batch-add-requests.test.ts b/test/basic-crawler/batch-add-requests.test.ts
similarity index 100%
rename from packages/basic-crawler/test/batch-add-requests.test.ts
rename to test/basic-crawler/batch-add-requests.test.ts
diff --git a/packages/basic-crawler/test/enqueue-links/add-enqueue-strategy-to-requests.test.ts b/test/basic-crawler/enqueue-links/add-enqueue-strategy-to-requests.test.ts
similarity index 100%
rename from packages/basic-crawler/test/enqueue-links/add-enqueue-strategy-to-requests.test.ts
rename to test/basic-crawler/enqueue-links/add-enqueue-strategy-to-requests.test.ts
diff --git a/packages/basic-crawler/test/enqueue-links/protocol-matching-based-on-strategy.test.ts b/test/basic-crawler/enqueue-links/protocol-matching-based-on-strategy.test.ts
similarity index 100%
rename from packages/basic-crawler/test/enqueue-links/protocol-matching-based-on-strategy.test.ts
rename to test/basic-crawler/enqueue-links/protocol-matching-based-on-strategy.test.ts
diff --git a/packages/basic-crawler/test/enqueue-links/user-data.test.ts b/test/basic-crawler/enqueue-links/user-data.test.ts
similarity index 100%
rename from packages/basic-crawler/test/enqueue-links/user-data.test.ts
rename to test/basic-crawler/enqueue-links/user-data.test.ts
diff --git a/packages/basic-crawler/test/enqueue-links/user-provided-patterns-with-enqueue-strategy.test.ts b/test/basic-crawler/enqueue-links/user-provided-patterns-with-enqueue-strategy.test.ts
similarity index 100%
rename from packages/basic-crawler/test/enqueue-links/user-provided-patterns-with-enqueue-strategy.test.ts
rename to test/basic-crawler/enqueue-links/user-provided-patterns-with-enqueue-strategy.test.ts
diff --git a/packages/basic-crawler/test/sitemap-request-loader.test.ts b/test/basic-crawler/sitemap-request-loader.test.ts
similarity index 99%
rename from packages/basic-crawler/test/sitemap-request-loader.test.ts
rename to test/basic-crawler/sitemap-request-loader.test.ts
index 8b733a814..de89a583f 100644
--- a/packages/basic-crawler/test/sitemap-request-loader.test.ts
+++ b/test/basic-crawler/sitemap-request-loader.test.ts
@@ -7,7 +7,7 @@ import { CrawlingRequest, SitemapRequestLoader } from '@crawlee/basic';
import { MemoryStorageBackend, type Request, serviceLocator } from '@crawlee/core';
import { sleep } from '@crawlee/utils';
import express from 'express';
-import { startExpressAppPromise } from '../../../test/shared/_helper.js';
+import { startExpressAppPromise } from '../shared/_helper.js';
// Express server for serving sitemaps
let url = 'http://localhost';
diff --git a/packages/basic-crawler/test/throttling-request-manager.test.ts b/test/basic-crawler/throttling-request-manager.test.ts
similarity index 100%
rename from packages/basic-crawler/test/throttling-request-manager.test.ts
rename to test/basic-crawler/throttling-request-manager.test.ts
diff --git a/packages/browser-pool/test/changing-page-options.test.ts b/test/browser-pool/changing-page-options.test.ts
similarity index 97%
rename from packages/browser-pool/test/changing-page-options.test.ts
rename to test/browser-pool/changing-page-options.test.ts
index f843370f4..6921930c9 100644
--- a/packages/browser-pool/test/changing-page-options.test.ts
+++ b/test/browser-pool/changing-page-options.test.ts
@@ -8,7 +8,7 @@ import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
import puppeteer from 'puppeteer';
-import { createProxyServer } from '../../../test/browser-pool/browser-plugins/create-proxy-server.js';
+import { createProxyServer } from './browser-plugins/create-proxy-server.js';
describe.each([
['Puppeteer', new PuppeteerPlugin(puppeteer, { useIncognitoPages: true })],
diff --git a/packages/browser-pool/test/multiple-plugins.test.ts b/test/browser-pool/multiple-plugins.test.ts
similarity index 100%
rename from packages/browser-pool/test/multiple-plugins.test.ts
rename to test/browser-pool/multiple-plugins.test.ts
diff --git a/packages/browser-pool/test/new-errors.test.ts b/test/browser-pool/new-errors.test.ts
similarity index 100%
rename from packages/browser-pool/test/new-errors.test.ts
rename to test/browser-pool/new-errors.test.ts
diff --git a/packages/browser-pool/test/no-hybrid-plugins.test.ts b/test/browser-pool/no-hybrid-plugins.test.ts
similarity index 100%
rename from packages/browser-pool/test/no-hybrid-plugins.test.ts
rename to test/browser-pool/no-hybrid-plugins.test.ts
diff --git a/packages/browser-pool/test/proxy-sugar.test.ts b/test/browser-pool/proxy-sugar.test.ts
similarity index 95%
rename from packages/browser-pool/test/proxy-sugar.test.ts
rename to test/browser-pool/proxy-sugar.test.ts
index 130ccfb03..be5b01679 100644
--- a/packages/browser-pool/test/proxy-sugar.test.ts
+++ b/test/browser-pool/proxy-sugar.test.ts
@@ -7,7 +7,7 @@ import playwright from 'playwright';
import type { Server as ProxyChainServer } from 'proxy-chain';
import puppeteer from 'puppeteer';
-import { createProxyServer } from '../../../test/browser-pool/browser-plugins/create-proxy-server.js';
+import { createProxyServer } from './browser-plugins/create-proxy-server.js';
describe.each([
['Puppeteer', new PuppeteerPlugin(puppeteer, { useIncognitoPages: true })],
diff --git a/packages/browser-pool/test/remote-browser.test.ts b/test/browser-pool/remote-browser.test.ts
similarity index 94%
rename from packages/browser-pool/test/remote-browser.test.ts
rename to test/browser-pool/remote-browser.test.ts
index df5dda360..fc42974a0 100644
--- a/packages/browser-pool/test/remote-browser.test.ts
+++ b/test/browser-pool/remote-browser.test.ts
@@ -5,13 +5,16 @@ import { vi } from 'vitest';
import { serviceLocator } from '@crawlee/core';
import type { CrawleeLogger } from '@crawlee/core';
-import { BrowserPool } from '../src/browser-pool.js';
-import { BROWSER_POOL_EVENTS } from '../src/events.js';
-import { PlaywrightPlugin } from '../src/playwright/playwright-plugin.js';
-import { RemotePlaywrightPlugin } from '../src/playwright/remote-playwright-plugin.js';
-import { RemotePuppeteerPlugin } from '../src/puppeteer/remote-puppeteer-plugin.js';
-import type { RemoteBrowserEndpoint, ResolvedRemoteEndpoint } from '../src/remote-browser-plugin.js';
-import { RemoteBrowserProvider } from '../src/remote-browser-provider.js';
+import { BrowserPool } from '../../packages/browser-pool/src/browser-pool.js';
+import { BROWSER_POOL_EVENTS } from '../../packages/browser-pool/src/events.js';
+import { PlaywrightPlugin } from '../../packages/browser-pool/src/playwright/playwright-plugin.js';
+import { RemotePlaywrightPlugin } from '../../packages/browser-pool/src/playwright/remote-playwright-plugin.js';
+import { RemotePuppeteerPlugin } from '../../packages/browser-pool/src/puppeteer/remote-puppeteer-plugin.js';
+import type {
+ RemoteBrowserEndpoint,
+ ResolvedRemoteEndpoint,
+} from '../../packages/browser-pool/src/remote-browser-plugin.js';
+import { RemoteBrowserProvider } from '../../packages/browser-pool/src/remote-browser-provider.js';
// ---------------------------------------------------------------------------
// Mock helpers
diff --git a/packages/cheerio-crawler/test/xml.test.ts b/test/cheerio-crawler/xml.test.ts
similarity index 92%
rename from packages/cheerio-crawler/test/xml.test.ts
rename to test/cheerio-crawler/xml.test.ts
index b6e84fbbc..8a3a32221 100644
--- a/packages/cheerio-crawler/test/xml.test.ts
+++ b/test/cheerio-crawler/xml.test.ts
@@ -3,7 +3,7 @@ import type { Server } from 'node:http';
import type { CheerioCrawlingContext } from '@crawlee/cheerio';
import { CheerioCrawler } from '@crawlee/cheerio';
-import { runExampleComServer } from '../../../test/shared/_helper.js';
+import { runExampleComServer } from '../shared/_helper.js';
let serverAddress = 'http://localhost:';
let port: number;
diff --git a/packages/core/test/core/configuration.test.ts b/test/core/configuration.test.ts
similarity index 100%
rename from packages/core/test/core/configuration.test.ts
rename to test/core/configuration.test.ts
diff --git a/test/core/crawlers/browser-crawler.test.ts b/test/core/crawlers/browser-crawler.test.ts
index 8d152299b..e8581d662 100644
--- a/test/core/crawlers/browser-crawler.test.ts
+++ b/test/core/crawlers/browser-crawler.test.ts
@@ -30,6 +30,9 @@ import type { TestCrawlingContext } from './basic-browser-crawler.js';
import { BrowserCrawlerTest } from './basic-browser-crawler.js';
import { ISession } from '@crawlee/types';
+// clearing/restoring mocks before each test would wipe the mocks of still-running concurrent tests
+vitest.setConfig({ clearMocks: false, restoreMocks: false });
+
describe('BrowserCrawler', () => {
let prevEnvHeadless: string;
let logLevel: number;
diff --git a/packages/core/test/log/base-crawlee-logger.test.ts b/test/core/log/base-crawlee-logger.test.ts
similarity index 98%
rename from packages/core/test/log/base-crawlee-logger.test.ts
rename to test/core/log/base-crawlee-logger.test.ts
index fb30c100c..bef49a369 100644
--- a/packages/core/test/log/base-crawlee-logger.test.ts
+++ b/test/core/log/base-crawlee-logger.test.ts
@@ -1,5 +1,5 @@
-import type { CrawleeLogger, CrawleeLoggerOptions } from '../../src/log.js';
-import { BaseCrawleeLogger, LogLevel } from '../../src/log.js';
+import type { CrawleeLogger, CrawleeLoggerOptions } from '../../../packages/core/src/log.js';
+import { BaseCrawleeLogger, LogLevel } from '../../../packages/core/src/log.js';
/** Minimal concrete implementation for testing. */
class TestLogger extends BaseCrawleeLogger {
diff --git a/packages/core/test/memory-storage/async-iteration.test.ts b/test/core/memory-storage/async-iteration.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/async-iteration.test.ts
rename to test/core/memory-storage/async-iteration.test.ts
diff --git a/packages/core/test/memory-storage/key-value-store/stream.test.ts b/test/core/memory-storage/key-value-store/stream.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/key-value-store/stream.test.ts
rename to test/core/memory-storage/key-value-store/stream.test.ts
diff --git a/packages/core/test/memory-storage/no-crash-on-big-buffers.test.ts b/test/core/memory-storage/no-crash-on-big-buffers.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/no-crash-on-big-buffers.test.ts
rename to test/core/memory-storage/no-crash-on-big-buffers.test.ts
diff --git a/packages/core/test/memory-storage/request-queue/forefront.test.ts b/test/core/memory-storage/request-queue/forefront.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/request-queue/forefront.test.ts
rename to test/core/memory-storage/request-queue/forefront.test.ts
diff --git a/packages/core/test/memory-storage/request-queue/handled-request-count-should-update.test.ts b/test/core/memory-storage/request-queue/handled-request-count-should-update.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/request-queue/handled-request-count-should-update.test.ts
rename to test/core/memory-storage/request-queue/handled-request-count-should-update.test.ts
diff --git a/packages/core/test/memory-storage/request-queue/in-progress.test.ts b/test/core/memory-storage/request-queue/in-progress.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/request-queue/in-progress.test.ts
rename to test/core/memory-storage/request-queue/in-progress.test.ts
diff --git a/packages/core/test/memory-storage/reverse-datataset-list.test.ts b/test/core/memory-storage/reverse-datataset-list.test.ts
similarity index 100%
rename from packages/core/test/memory-storage/reverse-datataset-list.test.ts
rename to test/core/memory-storage/reverse-datataset-list.test.ts
diff --git a/packages/core/test/request-queue/adding-the-same-request-should-not-call-the-api.test.ts b/test/core/request-queue/adding-the-same-request-should-not-call-the-api.test.ts
similarity index 100%
rename from packages/core/test/request-queue/adding-the-same-request-should-not-call-the-api.test.ts
rename to test/core/request-queue/adding-the-same-request-should-not-call-the-api.test.ts
diff --git a/packages/core/test/request-queue/request-queue.test.ts b/test/core/request-queue/request-queue.test.ts
similarity index 100%
rename from packages/core/test/request-queue/request-queue.test.ts
rename to test/core/request-queue/request-queue.test.ts
diff --git a/packages/core/test/core/service-locator.test.ts b/test/core/service-locator.test.ts
similarity index 100%
rename from packages/core/test/core/service-locator.test.ts
rename to test/core/service-locator.test.ts
diff --git a/packages/core/test/storages/open-storage-with-different-client-should-be-respected.test.ts b/test/core/storages/open-storage-with-different-client-should-be-respected.test.ts
similarity index 100%
rename from packages/core/test/storages/open-storage-with-different-client-should-be-respected.test.ts
rename to test/core/storages/open-storage-with-different-client-should-be-respected.test.ts
diff --git a/packages/fs-storage/test/async-iteration.test.ts b/test/fs-storage/async-iteration.test.ts
similarity index 100%
rename from packages/fs-storage/test/async-iteration.test.ts
rename to test/fs-storage/async-iteration.test.ts
diff --git a/packages/fs-storage/test/default-storage-layout.test.ts b/test/fs-storage/default-storage-layout.test.ts
similarity index 100%
rename from packages/fs-storage/test/default-storage-layout.test.ts
rename to test/fs-storage/default-storage-layout.test.ts
diff --git a/packages/fs-storage/test/key-value-store/adoption.test.ts b/test/fs-storage/key-value-store/adoption.test.ts
similarity index 100%
rename from packages/fs-storage/test/key-value-store/adoption.test.ts
rename to test/fs-storage/key-value-store/adoption.test.ts
diff --git a/packages/fs-storage/test/key-value-store/record-key-path-traversal.test.ts b/test/fs-storage/key-value-store/record-key-path-traversal.test.ts
similarity index 100%
rename from packages/fs-storage/test/key-value-store/record-key-path-traversal.test.ts
rename to test/fs-storage/key-value-store/record-key-path-traversal.test.ts
diff --git a/packages/fs-storage/test/key-value-store/special-keys.test.ts b/test/fs-storage/key-value-store/special-keys.test.ts
similarity index 100%
rename from packages/fs-storage/test/key-value-store/special-keys.test.ts
rename to test/fs-storage/key-value-store/special-keys.test.ts
diff --git a/packages/fs-storage/test/key-value-store/stream.test.ts b/test/fs-storage/key-value-store/stream.test.ts
similarity index 100%
rename from packages/fs-storage/test/key-value-store/stream.test.ts
rename to test/fs-storage/key-value-store/stream.test.ts
diff --git a/packages/fs-storage/test/no-crash-on-big-buffers.test.ts b/test/fs-storage/no-crash-on-big-buffers.test.ts
similarity index 96%
rename from packages/fs-storage/test/no-crash-on-big-buffers.test.ts
rename to test/fs-storage/no-crash-on-big-buffers.test.ts
index d165c1d71..e1427e9b3 100644
--- a/packages/fs-storage/test/no-crash-on-big-buffers.test.ts
+++ b/test/fs-storage/no-crash-on-big-buffers.test.ts
@@ -37,6 +37,6 @@ describe('KeyValueStore round-trips a large binary value', () => {
const record = await store.getValue('owo.zip');
expect(Buffer.isBuffer(record?.value)).toBe(true);
expect((record!.value as Buffer).length).toBe(size);
- expect(record!.value.equals(zip)).toBe(true);
+ expect((record!.value as Buffer).equals(zip)).toBe(true);
});
});
diff --git a/packages/fs-storage/test/request-queue/adapter.test.ts b/test/fs-storage/request-queue/adapter.test.ts
similarity index 100%
rename from packages/fs-storage/test/request-queue/adapter.test.ts
rename to test/fs-storage/request-queue/adapter.test.ts
diff --git a/packages/fs-storage/test/request-queue/prolong-request-lock.test.ts b/test/fs-storage/request-queue/prolong-request-lock.test.ts
similarity index 83%
rename from packages/fs-storage/test/request-queue/prolong-request-lock.test.ts
rename to test/fs-storage/request-queue/prolong-request-lock.test.ts
index 44ef0717c..845d4a983 100644
--- a/packages/fs-storage/test/request-queue/prolong-request-lock.test.ts
+++ b/test/fs-storage/request-queue/prolong-request-lock.test.ts
@@ -22,8 +22,8 @@ describe('FileSystemStorageBackend extendRequestProcessingTimeSecs', () => {
const locked = await queue.fetchNextRequest();
expect(locked).toBeDefined();
- expect(await queue.extendRequestProcessingTimeSecs(locked!.id!, 30)).toBe(true);
- expect(await queue.extendRequestProcessingTimeSecs('no-such-request', 30)).toBe(false);
+ expect(await queue.extendRequestProcessingTimeSecs!(locked!.id!, 30)).toBe(true);
+ expect(await queue.extendRequestProcessingTimeSecs!('no-such-request', 30)).toBe(false);
await queue.drop();
});
diff --git a/packages/fs-storage/test/request-queue/reload-persistence.test.ts b/test/fs-storage/request-queue/reload-persistence.test.ts
similarity index 100%
rename from packages/fs-storage/test/request-queue/reload-persistence.test.ts
rename to test/fs-storage/request-queue/reload-persistence.test.ts
diff --git a/packages/fs-storage/test/request-queue/request-queue-access.test.ts b/test/fs-storage/request-queue/request-queue-access.test.ts
similarity index 100%
rename from packages/fs-storage/test/request-queue/request-queue-access.test.ts
rename to test/fs-storage/request-queue/request-queue-access.test.ts
diff --git a/packages/fs-storage/test/reverse-datataset-list.test.ts b/test/fs-storage/reverse-datataset-list.test.ts
similarity index 100%
rename from packages/fs-storage/test/reverse-datataset-list.test.ts
rename to test/fs-storage/reverse-datataset-list.test.ts
diff --git a/packages/fs-storage/test/storage-layout.ts b/test/fs-storage/storage-layout.ts
similarity index 100%
rename from packages/fs-storage/test/storage-layout.ts
rename to test/fs-storage/storage-layout.ts
diff --git a/packages/fs-storage/test/storage-name-path-traversal.test.ts b/test/fs-storage/storage-name-path-traversal.test.ts
similarity index 100%
rename from packages/fs-storage/test/storage-name-path-traversal.test.ts
rename to test/fs-storage/storage-name-path-traversal.test.ts
diff --git a/packages/otel/test/constants.test.ts b/test/otel/constants.test.ts
similarity index 96%
rename from packages/otel/test/constants.test.ts
rename to test/otel/constants.test.ts
index ba0ad5229..0d4ae05a9 100644
--- a/packages/otel/test/constants.test.ts
+++ b/test/otel/constants.test.ts
@@ -1,6 +1,6 @@
import { SeverityNumber } from '@opentelemetry/api-logs';
-import { apifyLogLevelMap, apifyLogLevelNameMap, loggerMethods } from '../src/constants';
+import { apifyLogLevelMap, apifyLogLevelNameMap, loggerMethods } from '../../packages/otel/src/constants.js';
/**
* The mapping itself is a decision worth pinning down - `SOFT_FAIL` and `WARNING` collapse onto one OpenTelemetry
diff --git a/packages/otel/test/instrumentation.test.ts b/test/otel/instrumentation-config.test.ts
similarity index 99%
rename from packages/otel/test/instrumentation.test.ts
rename to test/otel/instrumentation-config.test.ts
index 8b21faff2..c013515c0 100644
--- a/packages/otel/test/instrumentation.test.ts
+++ b/test/otel/instrumentation-config.test.ts
@@ -3,7 +3,7 @@ import { ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from '@opentelemetry/semantic
import { isWrapped } from '@opentelemetry/instrumentation';
import { satisfies } from 'semver';
-import { baseConfig, requestHandlingInstrumentationMethods } from '../src/constants';
+import { baseConfig, requestHandlingInstrumentationMethods } from '../../packages/otel/src/constants.js';
describe('CrawleeInstrumentation', () => {
describe('constructor and configuration', () => {
diff --git a/packages/otel/test/patching.test.ts b/test/otel/patching.test.ts
similarity index 99%
rename from packages/otel/test/patching.test.ts
rename to test/otel/patching.test.ts
index 33b76b094..8314b4688 100644
--- a/packages/otel/test/patching.test.ts
+++ b/test/otel/patching.test.ts
@@ -1,6 +1,6 @@
import { CrawleeInstrumentation } from '@crawlee/otel';
import { SeverityNumber } from '@opentelemetry/api-logs';
-import type { LogRecord } from '@opentelemetry/sdk-logs';
+import type { ReadableLogRecord } from '@opentelemetry/sdk-logs';
import { InMemoryLogRecordExporter, LoggerProvider, SimpleLogRecordProcessor } from '@opentelemetry/sdk-logs';
import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
@@ -282,7 +282,7 @@ describe('log instrumentation', () => {
const error = new TypeError('boom');
new moduleExports.BaseCrawleeLogger().exception(error, 'failed');
- const record = logExporter.getFinishedLogRecords()[0] as LogRecord;
+ const record = logExporter.getFinishedLogRecords()[0] as ReadableLogRecord;
expect(record.severityNumber).toBe(SeverityNumber.ERROR);
expect(record.attributes[ATTR_EXCEPTION_TYPE]).toBe('TypeError');
expect(record.attributes[ATTR_EXCEPTION_MESSAGE]).toBe('boom');
diff --git a/packages/otel/test/utilities.test.ts b/test/otel/utilities.test.ts
similarity index 98%
rename from packages/otel/test/utilities.test.ts
rename to test/otel/utilities.test.ts
index 5a4bf8383..96e206234 100644
--- a/packages/otel/test/utilities.test.ts
+++ b/test/otel/utilities.test.ts
@@ -1,7 +1,7 @@
import type { ClassMethodToInstrument } from '@crawlee/otel';
import { diag } from '@opentelemetry/api';
-import { buildModuleDefinitions } from '../src/utilities';
+import { buildModuleDefinitions } from '../../packages/otel/src/utilities.js';
describe('buildModuleDefinitions', () => {
let diagWarnSpy: ReturnType<typeof vi.spyOn>;
diff --git a/packages/otel/test/wrap-with-span.test.ts b/test/otel/wrap-with-span.test.ts
similarity index 99%
rename from packages/otel/test/wrap-with-span.test.ts
rename to test/otel/wrap-with-span.test.ts
index 48264a8c5..bfa326701 100644
--- a/packages/otel/test/wrap-with-span.test.ts
+++ b/test/otel/wrap-with-span.test.ts
@@ -3,7 +3,7 @@ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { InMemorySpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
-import { setSharedTracer, wrapWithSpan } from '../src/wrap-with-span';
+import { setSharedTracer, wrapWithSpan } from '../../packages/otel/src/wrap-with-span.js';
describe('wrapWithSpan', () => {
let provider: NodeTracerProvider;
diff --git a/packages/utils/test/non-error-objects-working.test.ts b/test/utils/non-error-objects-working.test.ts
similarity index 73%
rename from packages/utils/test/non-error-objects-working.test.ts
rename to test/utils/non-error-objects-working.test.ts
index b6d848d1a..1c994434d 100644
--- a/packages/utils/test/non-error-objects-working.test.ts
+++ b/test/utils/non-error-objects-working.test.ts
@@ -1,4 +1,4 @@
-import { ErrorTracker } from '../../basic-crawler/src/internals/crawlers/error-tracker.js';
+import { ErrorTracker } from '../../packages/basic-crawler/src/internals/crawlers/error-tracker.js';
describe('ErrorTracker', () => {
test('processing a non-error error should not crash', () => {
diff --git a/packages/utils/test/robots.test.ts b/test/utils/robots.test.ts
similarity index 98%
rename from packages/utils/test/robots.test.ts
rename to test/utils/robots.test.ts
index e1cd969c0..e00e135c0 100644
--- a/packages/utils/test/robots.test.ts
+++ b/test/utils/robots.test.ts
@@ -2,7 +2,7 @@ import { FetchHttpClient } from '@crawlee/http-client';
import nock from 'nock';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
-import { RobotsTxtFile } from '../src/internals/robots.js';
+import { RobotsTxtFile } from '../../packages/utils/src/internals/robots.js';
const httpClient = new FetchHttpClient();
diff --git a/packages/utils/test/sitemap-esm.test.ts b/test/utils/sitemap-esm.test.ts
similarity index 95%
rename from packages/utils/test/sitemap-esm.test.ts
rename to test/utils/sitemap-esm.test.ts
index 0b20ce2ab..9a48a9ed2 100644
--- a/packages/utils/test/sitemap-esm.test.ts
+++ b/test/utils/sitemap-esm.test.ts
@@ -6,7 +6,7 @@ import { expect, it } from 'vitest';
it('parses XML sitemaps with the native Node ESM loader', async () => {
// Vitest synthesizes CJS named exports; a child process loads `sax` the way Node does for users.
- const root = resolve(__dirname, '../../..');
+ const root = resolve(__dirname, '../..');
const { stdout } = await promisify(execFile)(
process.execPath,
[
diff --git a/packages/utils/test/sitemap.test.ts b/test/utils/sitemap.test.ts
similarity index 99%
rename from packages/utils/test/sitemap.test.ts
rename to test/utils/sitemap.test.ts
index 70cef14f2..72b5a7501 100644
--- a/packages/utils/test/sitemap.test.ts
+++ b/test/utils/sitemap.test.ts
@@ -2,8 +2,8 @@ import { FetchHttpClient } from '@crawlee/http-client';
import nock from 'nock';
import { beforeEach, describe, expect, it } from 'vitest';
-import type { SitemapUrl } from '../src/internals/sitemap.js';
-import { discoverValidSitemaps, parseSitemap, Sitemap } from '../src/internals/sitemap.js';
+import type { SitemapUrl } from '../../packages/utils/src/internals/sitemap.js';
+import { discoverValidSitemaps, parseSitemap, Sitemap } from '../../packages/utils/src/internals/sitemap.js';
describe('Sitemap', () => {
beforeEach(() => {
diff --git a/packages/utils/test/url.test.ts b/test/utils/url.test.ts
similarity index 96%
rename from packages/utils/test/url.test.ts
rename to test/utils/url.test.ts
index 1988a3fb0..3229dc981 100644
--- a/packages/utils/test/url.test.ts
+++ b/test/utils/url.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { filterUrl, matchesEnqueueStrategy } from '../src/internals/url';
+import { filterUrl, matchesEnqueueStrategy } from '../../packages/utils/src/internals/url.js';
describe('matchesEnqueueStrategy', () => {
const match = (strategy: Parameters<typeof matchesEnqueueStrategy>[0], target: string, origin: string) =>
diff --git a/vitest.config.mts b/vitest.config.mts
index 72adf1051..d69f1b8ec 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -8,7 +8,6 @@ import { defaultExclude, defineConfig, mergeConfig } from 'vitest/config';
// They get their own project so `maxWorkers` can be capped independently, and `sequence.groupOrder`
// keeps them from running next to the cheap tests.
const browserTests = [
- 'packages/browser-pool/test/**/*.test.ts',
'test/browser-pool/**/*.test.ts',
'test/core/autoscaling/memory-info-v2.test.ts',
'test/core/browser-launchers/*.test.ts',