2
0
mirror of https://github.com/iconify/collections-json.git synced 2024-11-22 12:35:12 +00:00

test: add cjs tests

This commit is contained in:
Joaquín Sánchez Jiménez 2021-09-18 00:11:00 +02:00
parent 56ec61b291
commit 8754f02c92
4 changed files with 26 additions and 2 deletions

23
jest.config.cjs.ts Normal file
View File

@ -0,0 +1,23 @@
import type { Config } from '@jest/types'
// see https://jestjs.io/docs/ecmascript-modules
// Sync object
const config: Config.InitialOptions = {
verbose: true,
testMatch: [
'**/__tests__/**/*.+(ts|tsx|js)',
'**/?(*.)+(spec|test).+(ts|tsx|js)',
],
moduleDirectories: [
'node_modules',
'src',
],
moduleFileExtensions: ['ts', 'js'],
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
}
export default config

View File

@ -23,7 +23,8 @@
"bugs": "https://github.com/iconify/collections-json/issues", "bugs": "https://github.com/iconify/collections-json/issues",
"scripts": { "scripts": {
"build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts", "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts",
"test": "yarn build && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest" "test-esm": "yarn build && jest --clearCache && cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --config=jest.config.esm.ts",
"test-cjs": "yarn build && jest --clearCache && jest --config=jest.config.cjs.ts"
}, },
"dependencies": { "dependencies": {
"upath": "^2.0.1" "upath": "^2.0.1"

View File

@ -6,7 +6,7 @@ const cwd = process.cwd()
describe('locate', () => { describe('locate', () => {
test('mdi resolves the json collection', () => { test('mdi resolves the json collection', () => {
const received = locate('mdi') as string const received = locate('mdi') as string
const expected = resolve(cwd, 'json/', 'mdi.json').replace(/\\/g, '/') const expected = resolve(cwd, 'json', 'mdi.json').replace(/\\/g, '/')
expect(received).toBe(expected) expect(received).toBe(expected)
}) })
}) })