diff --git a/eslint.config.js b/eslint.config.js index 215827e..765ce8d 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,6 +6,7 @@ export default sxzz().append({ 'import/no-default-export': 'off', 'no-console': 'off', 'node/prefer-global/process': 'off', + 'unicorn/no-array-sort': 'off', 'unicorn/prefer-global-this': 'off', 'unicorn/prefer-string-replace-all': 'off', }, diff --git a/tests/conformance.test.ts b/tests/conformance.test.ts new file mode 100644 index 0000000..cef66ed --- /dev/null +++ b/tests/conformance.test.ts @@ -0,0 +1,39 @@ +import { createRequire } from 'node:module' +import { describe, expect, test } from 'vitest' + +const require = createRequire(import.meta.url) + +const removedAPIs = new Set([ + 'destroy', //deprecated + 'coerce', // private API + 'humanize', // private API + 'init', // private API + 'save', // private API + 'load', // private API + 'colors', // private API + 'useColors', // private API +]) + +describe('conformance', () => { + test('require: same exports', () => { + const debug = require('debug') + const obug = require('../dist/node') + const debugKeys = Object.keys(debug) + .filter((key) => !removedAPIs.has(key)) + .sort() + const obugKeys = Object.keys(obug).sort() + expect(obugKeys).toEqual(debugKeys) + }) + + test('import: same exports', async () => { + const debug = await import('debug') + const obug = await import('../dist/node') + const debugKeys = Object.keys(debug) + .filter((key) => !removedAPIs.has(key)) + .sort() + const obugKeys = Object.keys(obug) + .filter((key) => key !== 'createDebug' && key !== 'module.exports') + .sort() + expect(obugKeys).toEqual(debugKeys) + }) +})