Skip to content

Commit

Permalink
chore: add test for .aegir.ts config with ESM import
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Jun 23, 2022
1 parent 3afe119 commit 2cbe5c6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/config/fixtures/custom-ts-config-with-esm-import/.aegir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isWritableStream } from 'is-stream'

import type { PartialOptions } from '../../../../src/types';

const config: PartialOptions = {
debug: true,
test: {
before: async (opts) => {
console.log('isWritableStream: ', isWritableStream)
return { env: { res: '4321' } }
}
}
}

export default config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.aegir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
"extends": "../../../../package.json",
"parserOptions": {
"sourceType": "module",
"project": ["./tsconfig.json"]
},
"parser": "@typescript-eslint/parser",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "custom-config"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../../src/config/tsconfig.aegir.json",
"compilerOptions": {
"outDir": "dist",
"noEmit": true
},
"include": [
".aegir.ts",
]
}
12 changes: 12 additions & 0 deletions test/config/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ describe('config - user', () => {
expect(res && res.env?.res).to.eql('1234')
})

it('custom ts config with ESM import', async () => {
const conf = await config(getConfigSearchPath('fixtures/custom-ts-config-with-esm-import'))
expect(conf).to.have.property('debug').eql(true)
expect(conf).to.have.nested.property('test.before')
expect(conf).to.have.nested.property('test.after')

// @ts-ignore
const res = await conf.test.before()
expect(res).not.to.be.undefined()
expect(res && res.env?.res).to.eql('4321')
})

it('custom ts config without extension', async () => {
const conf = await config(getConfigSearchPath('fixtures/custom-ts-no-ext-config'))
expect(conf).to.have.property('debug').eql(true)
Expand Down

0 comments on commit 2cbe5c6

Please sign in to comment.