html-renderer-api 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-renderer-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Server API renders DOM with puppeteer to get HTML & Bypass Cloudflare bot check.",
5
5
  "main": "src/scrapers/scraper-cloudflare.js",
6
6
  "type": "module",
@@ -11,9 +11,15 @@
11
11
  },
12
12
  "scripts": {
13
13
  "start": "bun src/scrapers/scraper-cloudflare.js",
14
- "deploy": "wrangler deploy"
14
+ "deploy": "wrangler deploy",
15
+ "test": "vitest run",
16
+ "test:coverage": "vitest run --coverage"
15
17
  },
16
18
  "dependencies": {
17
19
  "@cloudflare/puppeteer": "*"
20
+ },
21
+ "devDependencies": {
22
+ "vitest": "^4.0.18",
23
+ "@vitest/coverage-v8": "^4.0.18"
18
24
  }
19
- }
25
+ }
@@ -0,0 +1,26 @@
1
+ import { describe, it, expect } from 'vitest';
2
+
3
+ // The package's declared entry point (src/scrapers/scraper-cloudflare.ts) is a
4
+ // Cloudflare Worker `fetch` handler that re-exports a Durable Object and
5
+ // transitively imports "@cloudflare/puppeteer", which expects the Cloudflare
6
+ // Workers runtime (wrangler) rather than plain Node. Importing it standalone
7
+ // under Vitest's node environment is not representative. Instead, per the
8
+ // fallback guidance, this smoke test imports a real pure utility module from
9
+ // within the package (src/utils/scraper-utils.ts) and exercises its actual
10
+ // exported functions.
11
+ describe('module smoke test', () => {
12
+ it('imports scraper-utils and exposes working exports', async () => {
13
+ const mod = await import('../src/utils/scraper-utils');
14
+ expect(mod).toBeDefined();
15
+ expect(typeof mod.parseRequestParams).toBe('function');
16
+ expect(typeof mod.authenticateRequest).toBe('function');
17
+
18
+ const request = new Request('https://example.com/?url=https://example.org&wait=100');
19
+ const params = await mod.parseRequestParams(request);
20
+ expect(params.url).toBe('https://example.org');
21
+ expect(params.wait).toBe(100);
22
+
23
+ const authResult = await mod.authenticateRequest(request, {} as any, params);
24
+ expect(authResult.success).toBe(true);
25
+ });
26
+ });
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ coverage: {
8
+ provider: 'v8',
9
+ reporter: ['text', 'json', 'html', 'lcov'],
10
+ exclude: [
11
+ 'node_modules/**',
12
+ 'dist/**',
13
+ '**/*.test.ts'
14
+ ]
15
+ }
16
+ }
17
+ });