-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from embroider-build/NullVoxPopuli-patch-4
Specify rootDir so that declarations can always be emitted with the correct paths.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
|
||
import fse from 'fs-extra'; | ||
import { afterAll, beforeAll, describe, expect, it } from 'vitest'; | ||
|
||
import { AddonHelper, dirContents } from '../helpers.js'; | ||
|
||
/** | ||
* These tests are to ensure that for typescript, we've configured the tsconfig.json correctly | ||
*/ | ||
describe(`declarations-configuration`, () => { | ||
let declarationsDir = ''; | ||
let helper = new AddonHelper({ | ||
packageManager: 'pnpm', | ||
args: ['--typescript'], | ||
scenario: 'explicit-imports', | ||
}); | ||
|
||
beforeAll(async () => { | ||
await helper.setup(); | ||
await helper.installDeps(); | ||
|
||
declarationsDir = path.join(helper.addonFolder, 'declarations'); | ||
}); | ||
|
||
afterAll(async () => { | ||
await helper.clean(); | ||
}); | ||
|
||
describe('rootDir', () => { | ||
it('there are no top-level files, only nested in folders', async () => { | ||
await fse.rm(path.join(helper.addonFolder, 'src'), { recursive: true }); | ||
await fse.mkdirp(path.join(helper.addonFolder, 'src/components')); | ||
await fs.writeFile(path.join(helper.addonFolder, 'src/components/example.ts'), '/* empty file */'); | ||
|
||
let buildResult = await helper.build(); | ||
|
||
expect(buildResult.exitCode).toEqual(0); | ||
|
||
expect(await dirContents(declarationsDir)).to.deep.equal([ | ||
'components', | ||
]); | ||
|
||
expect(await dirContents(path.join(declarationsDir, 'components'))).to.deep.equal([ | ||
'example.d.ts', | ||
'example.d.ts.map' | ||
]); | ||
}); | ||
}); | ||
}); |