Skip to content

Commit

Permalink
test(apidom-parser-adapter-yamo-1-2): run tests in ESM mode
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n committed Oct 23, 2024
1 parent 8a27501 commit 825ffbf
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 179 deletions.
86 changes: 33 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@commitlint/cli": "=19.4.1",
"@commitlint/config-conventional": "=19.4.1",
"@types/benchmark": "^2.1.5",
"@types/chai": "^4.3.20",
"@types/chai": "^5.0.0",
"@types/dedent": "=0.7.2",
"@types/jsdom-global": "^3.0.7",
"@types/mocha": "=10.0.9",
Expand All @@ -64,7 +64,7 @@
"@typescript-eslint/parser": "=7.18.0",
"babel-loader": "=9.1.3",
"benchmark": "=2.1.4",
"chai": "^4.5.0",
"chai": "^5.1.1",
"copyfiles": "=2.4.1",
"core-js": "=3.38.1",
"cross-env": "=7.0.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-parser-adapter-yaml-1-2/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**/*.js
/**/*.mjs
/**/*.cjs
/dist
/es
/cjs
/types
/config
/.nyc_output
/node_modules
/**/*.js
5 changes: 3 additions & 2 deletions packages/apidom-parser-adapter-yaml-1-2/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/src/**/*.mjs
/src/**/*.cjs
/test/**/*.mjs
/dist
/es
/cjs
/types
/wasm
/NOTICE
Expand Down
6 changes: 4 additions & 2 deletions packages/apidom-parser-adapter-yaml-1-2/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"recursive": true,
"spec": "test/**/*.ts",
"file": ["test/mocha-bootstrap.cjs"]
"spec": "test/**/*.mjs",
"loader": "./test/wasm-loader.mjs",
"file": ["test/mocha-bootstrap.mjs"],
"ignore": ["test/perf/**/*.mjs"]
}
26 changes: 13 additions & 13 deletions packages/apidom-parser-adapter-yaml-1-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
},
"type": "module",
"sideEffects": [
"./es/lexical-analysis/browser-patch.mjs",
"./cjs/lexical-analysis/browser-patch.cjs"
"./src/lexical-analysis/browser-patch.mjs",
"./src/lexical-analysis/browser-patch.cjs"
],
"unpkg": "./dist/apidom-parser-apdater-yaml-1-2.browser.min.js",
"main": "./cjs/adapter-node.cjs",
"main": "./src/adapter-node.cjs",
"exports": {
"types": "./types/dist.d.ts",
"node": {
"import": "./es/adapter-node.mjs",
"require": "./cjs/adapter-node.cjs"
"import": "./src/adapter-node.mjs",
"require": "./src/adapter-node.cjs"
},
"browser": {
"import": "./es/adapter-browser.mjs"
"import": "./src/adapter-browser.mjs"
},
"default": "./cjs/adapter-node.cjs"
"default": "./src/adapter-node.cjs"
},
"types": "./types/dist.d.ts",
"scripts": {
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
"build:es": "npm run build:wasm && npm run build:wasm:copy && cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
"build:cjs": "npm run build:wasm && npm run build:wasm:copy && BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
"build:es": "npm run build:wasm && npm run build:wasm:copy && cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
"build:cjs": "npm run build:wasm && npm run build:wasm:copy && BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
"build:umd:browser": "npm run build:wasm && npm run build:wasm:copy && cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
"build:wasm": "node ../../scripts/file-exists.js ../../node_modules/tree-sitter-yaml/tree-sitter-yaml.wasm && exit 0 || cd ../../node_modules/tree-sitter-yaml && cross-env BABEL_ENV=cjs NODE_OPTIONS='-r core-js/stable @babel/register' tree-sitter generate --abi=13 ./grammar.js && tree-sitter build-wasm && node-gyp rebuild",
"build:wasm:copy": "copyfiles -u 4 ../../node_modules/tree-sitter-yaml/tree-sitter-yaml.wasm wasm",
Expand All @@ -37,10 +37,10 @@
"clean": "rimraf ./es ./cjs ./dist ./types",
"typescript:check-types": "tsc --noEmit",
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha",
"perf": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/index.cjs",
"perf:lexical-analysis": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/lexical-analysis.cjs",
"perf:parse-syntactic-analysis-indirect": "cross-env NODE_ENV=test BABEL_ENV=cjs node ./test/perf/parse-syntactic-analysis-indirect.cjs",
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
"perf": "cross-env BABEL_ENV=es babel ./test/perf/index.ts --out-file ./test/perf/index.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/index.mjs",
"perf:lexical-analysis": "cross-env BABEL_ENV=es babel ./test/perf/lexical-analysis.ts --out-file ./test/perf/lexical-analysis.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/lexical-analysis.mjs",
"perf:parse-syntactic-analysis-indirect": "cross-env BABEL_ENV=es babel ./test/perf/parse-syntactic-analysis-indirect.ts --out-file ./test/perf/parse-syntactic-analysis-indirect.mjs --root-mode 'upward' && cross-env NODE_ENV=test node ./test/perf/parse-syntactic-analysis-indirect.mjs",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
"postpack": "rimraf NOTICE LICENSES"
},
Expand Down
39 changes: 28 additions & 11 deletions packages/apidom-parser-adapter-yaml-1-2/test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,32 @@
"mocha/no-top-level-hooks": 2,
"mocha/no-identical-title": 2,
"mocha/no-nested-tests": 2,
"mocha/no-exclusive-tests": 2
},
"overrides": [{
"files": ["mocha-bootstrap.cjs"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"@typescript-eslint/no-var-requires": 0
}
}]
"mocha/no-exclusive-tests": 2,
"import/no-relative-packages": 0,
"no-underscore-dangle": 0,
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE"],
"leadingUnderscore": "forbid"
},
{
"selector": "variable",
"format": null,
"filter": {
"regex": "^__dirname$",
"match": true
}
},
{
"selector": "variable",
"format": null,
"filter": {
"regex": "^__filename$",
"match": true
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { assert, expect } from 'chai';
import {
toValue,
Expand All @@ -11,6 +12,7 @@ import {

import * as adapter from '../src/adapter-browser';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const spec = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample-data.yaml')).toString();

describe('adapter-browser', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { assert, expect } from 'chai';
import { YamlTagError } from '@swagger-api/apidom-ast';
import {
Expand All @@ -12,6 +13,7 @@ import {

import * as adapter from '../../src/adapter-node';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const spec = fs.readFileSync(path.join(__dirname, '..', 'fixtures', 'sample-data.yaml')).toString();

describe('adapter-node', function () {
Expand Down Expand Up @@ -134,8 +136,8 @@ describe('adapter-node', function () {
tagKind: 'Scalar',
nodeCanonicalContent: undefined,
});
assert.include(error.tagPosition.start, { type: 'point', row: 0, column: 6, char: 6 });
assert.include(error.tagPosition.end, { type: 'point', row: 0, column: 18, char: 18 });
assert.include(error.tagPosition?.start, { type: 'point', row: 0, column: 6, char: 6 });
assert.include(error.tagPosition?.end, { type: 'point', row: 0, column: 18, char: 18 });
}
});
});
Expand All @@ -156,8 +158,8 @@ describe('adapter-node', function () {
tagKind: 'Scalar',
nodeCanonicalContent: 'value',
});
assert.include(error.tagPosition.start, { type: 'point', row: 0, column: 6, char: 6 });
assert.include(error.tagPosition.end, { type: 'point', row: 0, column: 11, char: 11 });
assert.include(error.tagPosition?.start, { type: 'point', row: 0, column: 6, char: 6 });
assert.include(error.tagPosition?.end, { type: 'point', row: 0, column: 11, char: 11 });
}
});
});
Expand Down
33 changes: 0 additions & 33 deletions packages/apidom-parser-adapter-yaml-1-2/test/mocha-bootstrap.cjs

This file was deleted.

Loading

0 comments on commit 825ffbf

Please sign in to comment.