Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix sourcemap test #83
  • Loading branch information
tbela99 committed Jul 7, 2025
commit 66002cb6d14c36bf0c762c24298393fd57ea8062
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"scripts": {
"build": "rollup -c;./build.sh dist/index.d.ts 'declare interface' 'declare type'",
"test": "web-test-runner \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.; mocha --reporter-options='maxDiffSize=1801920' \"test/**/node.spec.js\"",
"test:web": "web-test-runner \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.",
"test:node": "mocha --reporter-options='maxDiffSize=1801920' \"test/**/node.spec.js\"",
"test:cov": "c8 -x 'test/specs/**/*.js' -x dist/lib/validation/syntax.js -x 'dist/lib/validation/parser/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' \"test/**/node.spec.js\"",
"test:web-cov": "web-test-runner -x 'test/specs/**/*.js' -x dist/lib/validation/syntax.js,dist/lib/validation/parser \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=. --coverage",
Expand Down Expand Up @@ -51,21 +52,21 @@
"homepage": "https://github.com/tbela99/css-parser#readme",
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-typescript": "^12.1.2",
"@types/chai": "^5.2.1",
"@rollup/plugin-typescript": "^12.1.4",
"@types/chai": "^5.2.2",
"@types/mocha": "^10.0.10",
"@types/node": "^22.15.2",
"@types/web": "^0.0.226",
"@web/test-runner": "^0.20.1",
"@web/test-runner-playwright": "^0.11.0",
"@types/node": "^24.0.10",
"@types/web": "^0.0.245",
"@web/test-runner": "^0.20.2",
"@web/test-runner-playwright": "^0.11.1",
"c8": "^10.1.3",
"esno": "^4.8.0",
"mocha": "^11.1.0",
"playwright": "^1.52.0",
"rollup": "^4.40.0",
"mocha": "^11.7.1",
"playwright": "^1.53.2",
"rollup": "^4.44.2",
"rollup-plugin-dts": "^6.2.1",
"tslib": "^2.8.1"
}
Expand Down
2 changes: 1 addition & 1 deletion test/files/sourcemap/line-awesome-sourcemap.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/specs/code/import1.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export function run(describe, expect, transform, parse, render, dirname) {

const atRule = `
@import '${import.meta.dirname + '/../../files/css/color.css'}';
@import '${(import.meta.dirname ?? dirname(new URL(import.meta.url).pathname)) + '/../../files/css/color.css'}';
abbr[title], abbr[data-original-title] {
text-decoration: underline dotted;
-webkit-text-decoration: underline dotted;
Expand Down
2 changes: 1 addition & 1 deletion test/specs/code/import2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function run(describe, expect, transform, parse, render, dirname, readFil

describe('process import #2', function () {
it('process import #1', function () {
return readFile(import.meta.dirname + '/../../files/result/font-awesome-all.css').
return readFile((import.meta.dirname ?? dirname(new URL(import.meta.url).pathname)) + '/../../files/result/font-awesome-all.css').
then(file => transform(import1, {
minify: false,
resolveImport: true
Expand Down
2 changes: 1 addition & 1 deletion test/specs/code/malformed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function run(describe, expect, transform, parse, render, dirname, readFil
const css = `
@import 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.css`;

return readFile(import.meta.dirname + '/../../files/result/font-awesome-all.css', {encoding: 'utf-8'}).
return readFile((import.meta.dirname ?? dirname(new URL(import.meta.url).pathname)) + '/../../files/result/font-awesome-all.css', {encoding: 'utf-8'}).
then(content => transform(css, {minify: false, resolveImport: true}).then(result => expect(result.code).equals(content)));
});

Expand Down
4 changes: 2 additions & 2 deletions test/specs/code/sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export function run(describe, expect, transform, parse, render, dirname, readFil

describe('sourcemap', function () {

const dir = import.meta.dirname + '/../..';
const dir = (import.meta.dirname ?? dirname(new URL(import.meta.url).pathname)) + '/../..';
const file = `@import '${dir}/files/css/line-awesome.css`;
const options = {
// minify: true,
// preserveLicense: true,
src: `${dir}/line-awesome.css`,
src: `${dir}/files/css/line-awesome.css`,
resolveImport: true,
sourcemap: true,
nestingRules: false
Expand Down