Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump ts-playwright-test-runner Playwright and Node version #307

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions templates/js-crawlee-playwright-chrome/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
const crawler = new PlaywrightCrawler({
proxyConfiguration,
requestHandler: router,
launchContext: {
launchOptions: {
args: [
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
]
}
}
});

await crawler.run(startUrls);
Expand Down
7 changes: 7 additions & 0 deletions templates/js-crawlee-puppeteer-chrome/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
const crawler = new PuppeteerCrawler({
proxyConfiguration,
requestHandler: router,
launchContext: {
launchOptions: {
args: [
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
]
}
}
});

// Run the crawler with the start URLs and wait for it to finish.
Expand Down
3 changes: 3 additions & 0 deletions templates/python-crawlee-playwright/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ async def main() -> None:
# Limit the crawl to max requests. Remove or increase it for crawling all links.
max_requests_per_crawl=50,
headless=True,
browser_options={
'args': ['--disable-gpu'],
}
)

# Define a request handler, which will be called for every request.
Expand Down
2 changes: 1 addition & 1 deletion templates/python-playwright/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def main() -> None:
# Launch Playwright and open a new browser context.
async with async_playwright() as playwright:
# Configure the browser to launch in headless mode as per Actor configuration.
browser = await playwright.chromium.launch(headless=Actor.config.headless)
browser = await playwright.chromium.launch(headless=Actor.config.headless, args=['--disable-gpu'])
context = await browser.new_context()

# Process the URLs from the request queue.
Expand Down
7 changes: 7 additions & 0 deletions templates/ts-crawlee-playwright-chrome/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ const crawler = new PlaywrightCrawler({
proxyConfiguration,
maxRequestsPerCrawl,
requestHandler: router,
launchContext: {
launchOptions: {
args: [
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
]
}
}
});

await crawler.run(startUrls);
Expand Down
7 changes: 7 additions & 0 deletions templates/ts-crawlee-puppeteer-chrome/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ const proxyConfiguration = await Actor.createProxyConfiguration();
const crawler = new PuppeteerCrawler({
proxyConfiguration,
requestHandler: router,
launchContext: {
launchOptions: {
args: [
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
]
}
}
});

// Run the crawler with the start URLs and wait for it to finish.
Expand Down
2 changes: 1 addition & 1 deletion templates/ts-playwright-test-runner/.actor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM apify/actor-node-playwright:20-1.37.1
FROM apify/actor-node-playwright:22-1.49.1

COPY package*.json ./

Expand Down
1 change: 1 addition & 0 deletions templates/ts-playwright-test-runner/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ storage
# generated test results
playwright-report
test-results.json
test-results

# installed files
node_modules
Expand Down
1 change: 1 addition & 0 deletions templates/ts-playwright-test-runner/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist
playwright-report
src/tests
test-results.json
test-results/
2 changes: 1 addition & 1 deletion templates/ts-playwright-test-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@apify/eslint-config-ts": "^0.3.0",
"@apify/tsconfig": "^0.1.0",
"@playwright/test": "1.37.1",
"@playwright/test": "1.49.1",
"@types/uuid": "^9.0.4",
"apify": "^3.2.6",
"tsx": "^4.6.2",
Expand Down
5 changes: 5 additions & 0 deletions templates/ts-playwright-test-runner/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export default defineConfig({
colorScheme: '${darkMode ? 'dark' : 'light'}',
locale: '${locale}',
video: '${video}',
launchOptions: {
args: [
'--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers
]
},
},
reporter: [
['html', { outputFolder: '${getResultDir()}', open: 'never' }],
Expand Down
8 changes: 6 additions & 2 deletions templates/ts-playwright-test-runner/tests/first.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { test, expect } from '@playwright/test';
test('has appropriate size', async ({ page }) => {
let totalDownloaded = 0;

await page.on('response', async (r) => {
totalDownloaded += await (await r.body()).byteLength;
await page.on('response', (r) => {
r.body().then((b) => {
totalDownloaded += b.byteLength;
}).catch(() => {
// Ignore errors.
});
});

await page.goto('https://apify.com/about', { waitUntil: 'networkidle' });
Expand Down
Loading