Skip to content

Commit 6e48b85

Browse files
authored
chore(ci): fix failing e2e tests (#456)
Fixes failing E2E tests (updates dependencies and edits the test assertions based on the current contents of `crawlee.dev`). Closes #363
1 parent 0854be1 commit 6e48b85

File tree

19 files changed

+36
-33
lines changed

19 files changed

+36
-33
lines changed

.github/workflows/test-e2e.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ jobs:
4040
restore-keys: |
4141
turbo-${{ github.job }}-${{ github.ref_name }}-
4242
43-
- name: Login to Apify
44-
run: npx -y apify-cli login -t ${{ secrets.APIFY_SCRAPER_TESTS_API_TOKEN }}
45-
4643
- name: Install Dependencies
4744
run: npm ci --force
4845

@@ -51,3 +48,5 @@ jobs:
5148

5249
- name: Test
5350
run: npm run test:e2e
51+
env:
52+
APIFY_TOKEN: ${{ secrets.APIFY_SCRAPER_TESTS_API_TOKEN }}

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"@apify/consts": "^2.29.0",
6868
"@apify/eslint-config": "^1.0.0",
6969
"@apify/input_secrets": "^1.2.0",
70+
"@apify/log": "^2.5.22",
7071
"@apify/tsconfig": "^0.1.0",
7172
"@commitlint/config-conventional": "^19.2.2",
7273
"@playwright/browser-chromium": "^1.46.0",

test/e2e/runScraperTests.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { dirname, join } from 'node:path';
44
import { fileURLToPath } from 'node:url';
55
import { isMainThread, Worker, workerData } from 'node:worker_threads';
66

7-
import { log } from '@apify/log';
7+
import log from '@apify/log';
88

99
import { clearStorage, colors, SKIPPED_TEST_CLOSE_CODE } from './tools.mjs';
1010

test/e2e/runSdkTests.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isMainThread, Worker, workerData } from 'node:worker_threads';
88
import { ApifyClient } from 'apify-client';
99

1010
import { ACTOR_SOURCE_TYPES } from '@apify/consts';
11-
import { log } from '@apify/log';
11+
import log from '@apify/log';
1212
import { cryptoRandomObjectId } from '@apify/utilities';
1313

1414
const rootPath = dirname(fileURLToPath(import.meta.url));
@@ -51,6 +51,8 @@ async function runWorker(dirName) {
5151
log.info('Captured stderr:');
5252
process.stderr.write(err);
5353
}
54+
55+
process.exit(exitCode);
5456
} else {
5557
log.info(`${dirName} OK`);
5658
}

test/e2e/scrapers/cheerio-default/test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const { exit } = process;
1313
process.exit = () => {};
1414

1515
await run(testDir, 'cheerio-scraper', {
16-
startUrls: [{ url: 'https://crawlee.dev' }],
16+
startUrls: [{ url: 'https://crawlee.dev/js/docs/guides/request-storage' }],
1717
keepUrlFragments: false,
18-
globs: ['https://crawlee.dev/*/*'],
18+
globs: ['https://crawlee.dev/js/docs/guides/**'],
1919
linkSelector: 'a',
2020
pageFunction: async function pageFunction(context) {
2121
const { $, request, log } = context;

test/e2e/scrapers/cheerio-ignoreSslErrors-enabled/test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ await run(testDir, 'cheerio-scraper', {
6565
process.exit = exit;
6666

6767
const stats = await getStats(testDir);
68-
await expect(stats.requestsFinished > 20, 'All requests finished');
68+
await expect(stats.requestsFinished >= 20, 'All requests finished');
6969

7070
const datasetItems = await getDatasetItems(testDir);
71-
await expect(datasetItems.length > 20, 'Minimum number of dataset items');
71+
await expect(datasetItems.length >= 20, 'Minimum number of dataset items');
7272
await expect(
7373
validateDataset(datasetItems, ['url', 'title']),
7474
'Dataset items validation',

test/e2e/scrapers/cheerio-max-requests/test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ await run(testDir, 'cheerio-scraper', {
8585
process.exit = exit;
8686

8787
const stats = await getStats(testDir);
88-
await expect(stats.requestsFinished > 10, 'All requests finished');
88+
await expect(stats.requestsFinished >= 10, 'All requests finished');
8989

9090
const datasetItems = await getDatasetItems(testDir);
9191
await expect(

test/e2e/scrapers/jsdom-default/test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const { exit } = process;
1313
process.exit = () => {};
1414

1515
await run(testDir, 'jsdom-scraper', {
16-
startUrls: [{ url: 'https://crawlee.dev' }],
16+
startUrls: [{ url: 'https://crawlee.dev/js/docs/guides/request-storage' }],
1717
keepUrlFragments: false,
18-
globs: ['https://crawlee.dev/*/*'],
18+
globs: ['https://crawlee.dev/js/docs/guides/**'],
1919
linkSelector: 'a',
2020
pageFunction: async function pageFunction(context) {
2121
const { window, request, log } = context;

test/e2e/scrapers/jsdom-max-requests/test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ await run(testDir, 'jsdom-scraper', {
8989
process.exit = exit;
9090

9191
const stats = await getStats(testDir);
92-
await expect(stats.requestsFinished > 10, 'All requests finished');
92+
await expect(stats.requestsFinished >= 10, 'All requests finished');
9393

9494
const datasetItems = await getDatasetItems(testDir);
9595
await expect(

0 commit comments

Comments
 (0)