mirror of
https://github.com/iconify/collections-json.git
synced 2024-11-21 20:15:12 +00:00
chore: add jest with esm and include a simple test
This commit is contained in:
parent
0b0bf01ca6
commit
689daad512
28
jest.config.ts
Normal file
28
jest.config.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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',
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
'ts-jest': {
|
||||||
|
useESM: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
@ -23,17 +23,23 @@
|
|||||||
"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": "esno src/test.ts"
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"upath": "^2.0.1"
|
"upath": "^2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "^0.9.0",
|
"@antfu/eslint-config": "^0.9.0",
|
||||||
|
"@types/jest": "^27.0.1",
|
||||||
"@types/node": "^16.9.1",
|
"@types/node": "^16.9.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"esno": "^0.9.1",
|
"esno": "^0.9.1",
|
||||||
|
"jest": "^27.2.0",
|
||||||
|
"jest-each": "^27.2.0",
|
||||||
|
"ts-jest": "^27.0.5",
|
||||||
|
"ts-node": "^10.2.1",
|
||||||
"tsup": "^4.14.0",
|
"tsup": "^4.14.0",
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
}
|
}
|
||||||
|
12
src/locate.test.ts
Normal file
12
src/locate.test.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { resolve } from 'path'
|
||||||
|
import { locate } from '../dist'
|
||||||
|
|
||||||
|
const cwd = process.cwd()
|
||||||
|
|
||||||
|
describe('locate', () => {
|
||||||
|
test('mdi resolves the json collection', () => {
|
||||||
|
const received = locate('mdi') as string
|
||||||
|
const expected = resolve(cwd, 'json/', 'mdi.json').replace(/\\/g, '/')
|
||||||
|
expect(received).toBe(expected)
|
||||||
|
})
|
||||||
|
})
|
12
src/test.ts
12
src/test.ts
@ -1,12 +0,0 @@
|
|||||||
import { lookupCollection, locate, lookupCollections } from '.'
|
|
||||||
|
|
||||||
const test = async(): Promise<void> => {
|
|
||||||
const fa = locate('fa')
|
|
||||||
console.log(fa)
|
|
||||||
const faLib = await lookupCollection('fa')
|
|
||||||
console.log(faLib)
|
|
||||||
const allCollections = await lookupCollections()
|
|
||||||
console.log(allCollections.fa)
|
|
||||||
}
|
|
||||||
|
|
||||||
test()
|
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"target": "es2017",
|
"target": "ESNext",
|
||||||
"lib": ["ESNext"],
|
"lib": ["ESNext"],
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user