Skip to content

Commit

Permalink
test(apidom-ns-openapi-3-0): 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 11faaf6 commit c50e8b3
Show file tree
Hide file tree
Showing 42 changed files with 61 additions and 41 deletions.
6 changes: 3 additions & 3 deletions packages/apidom-ns-openapi-3-0/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**/*.js
/**/*.mjs
/**/*.cjs
/dist
/es
/cjs
/config
/types
/.eslintrc.js
/.nyc_output
/node_modules
/**/*.js
5 changes: 3 additions & 2 deletions packages/apidom-ns-openapi-3-0/.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
/NOTICE
/swagger-api-apidom-ns-openapi-3-0-*.tgz
4 changes: 2 additions & 2 deletions packages/apidom-ns-openapi-3-0/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"recursive": true,
"spec": "test/**/*.ts",
"file": ["test/mocha-bootstrap.cjs"]
"spec": "test/**/*.mjs",
"file": ["test/mocha-bootstrap.mjs"]
}
24 changes: 12 additions & 12 deletions packages/apidom-ns-openapi-3-0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
},
"type": "module",
"sideEffects": [
"./es/refractor/registration.mjs",
"./cjs/refractor/registration.cjs"
"./src/refractor/registration.mjs",
"./src/refractor/registration.cjs"
],
"unpkg": "./dist/apidom-ns-openapi-3-0.browser.min.js",
"main": "./cjs/index.cjs",
"main": "./src/index.cjs",
"exports": {
"types": "./types/dist.d.ts",
"import": "./es/index.mjs",
"require": "./cjs/index.cjs"
"import": "./src/index.mjs",
"require": "./src/index.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": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'",
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
"build:umd:browser": "cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress",
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "rimraf ./es ./cjs ./dist ./types",
"test": "cross-env NODE_ENV=test BABEL_ENV=cjs mocha",
"test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 BABEL_ENV=cjs mocha",
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
"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",
"test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 mocha",
"typescript:check-types": "tsc --noEmit",
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
Expand All @@ -51,9 +51,9 @@
"ts-mixer": "^6.0.3"
},
"files": [
"cjs/",
"src/**/*.mjs",
"src/**/*.cjs",
"dist/",
"es/",
"types/dist.d.ts",
"LICENSES",
"NOTICE",
Expand Down
38 changes: 27 additions & 11 deletions packages/apidom-ns-openapi-3-0/test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,31 @@
"mocha/no-nested-tests": 2,
"mocha/no-exclusive-tests": 2,
"max-classes-per-file": 0,
"@typescript-eslint/no-unused-expressions": 0
},
"overrides": [{
"files": ["mocha-bootstrap.cjs"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"@typescript-eslint/no-var-requires": 0
}
}]
"@typescript-eslint/no-unused-expressions": 0,
"import/no-relative-packages": 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
}
}
]
}
}
11 changes: 0 additions & 11 deletions packages/apidom-ns-openapi-3-0/test/mocha-bootstrap.cjs

This file was deleted.

11 changes: 11 additions & 0 deletions packages/apidom-ns-openapi-3-0/test/mocha-bootstrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as chai from 'chai';
import { jestSnapshotPlugin, addSerializer } from 'mocha-chai-jest-snapshot';

// @ts-ignore
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom';
// @ts-ignore
import * as jestStringSerializer from '../../../scripts/jest-serializer-string';

chai.use(jestSnapshotPlugin());
addSerializer(jestApiDOMSerializer);
addSerializer(jestStringSerializer);
3 changes: 3 additions & 0 deletions packages/apidom-ns-openapi-3-0/test/refractor/index.ts
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 sinon from 'sinon';
import { ObjectElement, toValue, Namespace } from '@swagger-api/apidom-core';
Expand All @@ -16,6 +17,8 @@ import {
} from '../../src';
import * as predicates from '../../src/predicates';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

describe('refractor', function () {
context('given generic ApiDOM object in OpenApi 3.0.3 shape', function () {
specify('should refract to OpenApi 3.0 Element', function () {
Expand Down

0 comments on commit c50e8b3

Please sign in to comment.