-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(test): ensure tsdx.config.js w/ rollup-plugin-postcss works
- add and import a basic CSS file in build-withConfig - use the existing tsdx.config.js for the rollup config - ensure that one CSS file gets extracted at the end - ensure that it is properly autoprefixed and minifed too
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
test/integration-tests/fixtures/build-withConfig/src/index.css
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,4 @@ | ||
/* ::placeholder should be autoprefixed, and everything minified */ | ||
.test::placeholder { | ||
color: 'blue'; | ||
} |
2 changes: 2 additions & 0 deletions
2
test/integration-tests/fixtures/build-withConfig/src/index.ts
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,64 @@ | ||
const shell = require('shelljs'); | ||
const fs = require('fs-extra'); | ||
|
||
const util = require('../utils/fixture'); | ||
const { execWithCache } = require('../utils/shell'); | ||
|
||
shell.config.silent = false; | ||
|
||
const testDir = 'integration-tests'; | ||
const fixtureName = 'build-withConfig'; | ||
const stageName = `stage-integration-${fixtureName}`; | ||
|
||
describe('integration :: tsdx build :: tsdx.config.js', () => { | ||
beforeAll(() => { | ||
util.teardownStage(stageName); | ||
util.setupStageWithFixture(testDir, stageName, fixtureName); | ||
}); | ||
|
||
it('should create a CSS file in the dist/ directory', () => { | ||
const output = execWithCache('node ../dist/index.js build'); | ||
|
||
// TODO: this is kind of subpar naming, rollup-plugin-postcss just names it | ||
// the same as the output file, but with the .css extension | ||
expect(shell.test('-f', 'dist/build-withconfig.cjs.development.css')); | ||
|
||
expect(output.code).toBe(0); | ||
}); | ||
|
||
it('should autoprefix and minify the CSS file', async () => { | ||
const output = execWithCache('node ../dist/index.js build'); | ||
|
||
const cssText = await fs.readFile( | ||
'./dist/build-withconfig.cjs.development.css' | ||
); | ||
|
||
// autoprefixed and minifed output | ||
expect( | ||
cssText.includes('.test::-webkit-input-placeholder{color:"blue"}') | ||
).toBeTruthy(); | ||
|
||
expect(output.code).toBe(0); | ||
}); | ||
|
||
it('should compile files into a dist directory', () => { | ||
const output = execWithCache('node ../dist/index.js build'); | ||
|
||
expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-withconfig.cjs.development.js') | ||
).toBeTruthy(); | ||
expect( | ||
shell.test('-f', 'dist/build-withconfig.cjs.production.min.js') | ||
).toBeTruthy(); | ||
expect(shell.test('-f', 'dist/build-withconfig.esm.js')).toBeTruthy(); | ||
|
||
expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); | ||
|
||
expect(output.code).toBe(0); | ||
}); | ||
|
||
afterAll(() => { | ||
util.teardownStage(stageName); | ||
}); | ||
}); |