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

TypeError: process.getBuiltinModule is not a function #86

Open
eneskuehn opened this issue Dec 12, 2024 · 1 comment
Open

TypeError: process.getBuiltinModule is not a function #86

eneskuehn opened this issue Dec 12, 2024 · 1 comment

Comments

@eneskuehn
Copy link

eneskuehn commented Dec 12, 2024

Do you happen to know what might be the issue? the comparePdfToSnapshot method is failing with:

TypeError: process.getBuiltinModule is not a function
at NodeCanvasFactory._createCanvas (node_modules\pdfjs-dist\legacy\build\webpack:\pdf.js\src\display\node_utils.js:84:8)
at NodeCanvasFactory.create (node_modules\pdfjs-dist\legacy\build\webpack:\pdf.js\src\display\canvas_factory.js:35:25)
at node_modules\pdf-visual-diff\src\pdf2png\pdf2png.ts:56:46
at handleMissingSnapshot (node_modules\pdf-visual-diff\src\compare-pdf-to-snapshot.ts:212:18)
at tests\smoke-tests\pdf.spec.ts:15:18

my playwright test code:
test('Compare pdf-visual-diff', async () => {
const pathToPdf = path.resolve('.test-data', 'smoke-tests', 'temp-files', 'pdf', 'check_20140219_001.pdf');
const fileContent = fs.readFileSync(pathToPdf);
const result = await comparePdfToSnapshot(fileContent, __dirname, 'report', {
failOnMissingSnapshot: false,
});
console.log(result);
});`

test output:
Running 1 test using 1 worker
Warning: Cannot polyfill DOMMatrix, rendering may be broken.
Warning: Cannot polyfill ImageData, rendering may be broken.
Warning: Cannot polyfill Path2D, rendering may be broken.
F

  1. [testing] › smoke-tests\pdf.spec.ts:7:5 › Compare pdf-visual-diff ──────────────────────────────
TypeError: process.getBuiltinModule is not a function

   8 |   const pathToPdf = path.resolve('.test-data', 'smoke-tests', 'temp-files', 'pdf', 'check_20140219_001.pdf');
   9 |   const fileContent = fs.readFileSync(pathToPdf);
> 10 |   const result = await comparePdfToSnapshot(fileContent, __dirname, 'report', {
     |                  ^
  11 |     failOnMissingSnapshot: false,
  12 |   });
  13 |   console.log(result);

    at NodeCanvasFactory._createCanvas (C:\xxx\test-automation\node_modules\pdfjs-dist\legacy\build\webpack:\pdf.js\src\display\node_utils.js:84:8)
    at NodeCanvasFactory.create (C:\xxx\test-automation\node_modules\pdfjs-dist\legacy\build\webpack:\pdf.js\src\display\canvas_factory.js:35:25)
    at C:\xxx\test-automation\node_modules\pdf-visual-diff\src\pdf2png\pdf2png.ts:56:46
    at handleMissingSnapshot (C:\Jopari\test-automation\node_modules\pdf-visual-diff\src\compare-pdf-to-snapshot.ts:212:18)
    at C:\xxx\test-automation\tests\smoke-tests\pdf.spec.ts:10:18

1 failed
[testing] › smoke-tests\pdf.spec.ts:7:5 › Compare pdf-visual-diff ───────────────────────────────

configuration:
node v20.15.0
npm 10.7.0
pdf-visual-diff 0.14.0

@moshensky
Copy link
Owner

moshensky commented Dec 12, 2024

I believe this is due to the Node.js version. Could you try using the v20 LTS, specifically version 20.18.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants