Skip to content

Commit 73fb65c

Browse files
committed
Fix browser tests to use pre-built dist files
The browser tests were failing because Karma was trying to load individual TypeScript source files, which import with .js extensions that don't exist as separate files (they're now .ts files). Changes: - Updated test/unit/asyncImportHelper.js to import from /base/dist/jspdf.es.js instead of /base/src/index.ts - Simplified test/unit/karma.conf.js to serve the pre-built dist files - Removed unnecessary TypeScript preprocessing from karma config since we're using the already-compiled dist files This approach is cleaner because: 1. It matches how users will actually consume the library 2. It avoids complex on-the-fly TypeScript transpilation in the browser 3. It eliminates 404 errors for .js files that don't exist 4. It ensures tests run against the actual built artifacts The build must be run before tests (which CI already does), and browser tests will now use the production ES module build.
1 parent 9b9941e commit 73fb65c

File tree

10 files changed

+19
-32
lines changed

10 files changed

+19
-32
lines changed

dist/jspdf.es.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T19:40:29.937Z
5-
* CommitID 28b15316e4
4+
* Version 3.0.3 Built on 2025-11-09T19:51:50.170Z
5+
* CommitID 9b9941edcc
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com

dist/jspdf.es.min.js

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

dist/jspdf.node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T19:40:29.976Z
5-
* CommitID 28b15316e4
4+
* Version 3.0.3 Built on 2025-11-09T19:51:50.204Z
5+
* CommitID 9b9941edcc
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com

dist/jspdf.node.min.js

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

dist/jspdf.umd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T19:40:29.899Z
5-
* CommitID 28b15316e4
4+
* Version 3.0.3 Built on 2025-11-09T19:51:50.135Z
5+
* CommitID 9b9941edcc
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com

dist/jspdf.umd.min.js

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

dist/polyfills.es.js

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

dist/polyfills.umd.js

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

test/unit/asyncImportHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
AcroFormTextField,
1313
AcroFormPasswordField,
1414
AcroFormAppearance
15-
} from "/base/src/index.ts";
15+
} from "/base/dist/jspdf.es.js";
1616

1717
window.importsReady({
1818
jsPDF,

test/unit/karma.conf.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Karma configuration
22
"use strict";
33
const karmaConfig = require("../karma.common.conf.js");
4-
const resolve = require("rollup-plugin-node-resolve");
5-
const typescript = require("@rollup/plugin-typescript");
64

75
module.exports = config => {
86
config.set({
@@ -17,7 +15,8 @@ module.exports = config => {
1715
watched: true,
1816
type: "module"
1917
},
20-
{ pattern: "src/**/*.ts", included: false },
18+
{ pattern: "dist/jspdf.es.js", included: false },
19+
{ pattern: "dist/jspdf.es.js.map", included: false },
2120
"node_modules/canvg/lib/umd.js",
2221
"node_modules/html2canvas/dist/html2canvas.js",
2322
"node_modules/dompurify/dist/purify.js",
@@ -37,18 +36,6 @@ module.exports = config => {
3736
served: true
3837
}
3938
],
40-
preprocessors: {
41-
"src/libs/fflate.ts": ["rollup"],
42-
"src/libs/fast-png.ts": ["rollup"]
43-
},
44-
45-
rollupPreprocessor: {
46-
plugins: [typescript({ tsconfig: "./tsconfig.json" }), resolve()],
47-
output: {
48-
format: "es",
49-
sourcemap: "inline"
50-
}
51-
},
5239

5340
browsers: ["ChromeHeadless"],
5441
// test results reporter to use

0 commit comments

Comments
 (0)