Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const preprocessor = (options = {}) => {
// we're provided a default output path that lives alongside Cypress's
// app data files so we don't have to worry about where to put the bundled
// file on disk
const outputPath = file.outputPath
const outputPath = path.extname(file.outputPath) === '.js'
? file.outputPath
: `${file.outputPath}.js`

// we need to set entry and output
webpackOptions = Object.assign(webpackOptions, {
Expand Down
19 changes: 19 additions & 0 deletions test/unit/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ describe('webpack preprocessor', function () {
})
})

it('adds .js extension to filename when the originating file had been no javascript file', function () {
this.file.outputPath = 'output/output.ts'

return this.run().then(() => {
expect(webpack.lastCall.args[0].output).to.eql({
path: 'output',
filename: 'output.ts.js',
})
})
})

it('enables inline source maps', function () {
return this.run().then(() => {
expect(webpack.lastCall.args[0].devtool).to.equal('inline-source-map')
Expand Down Expand Up @@ -179,6 +190,14 @@ describe('webpack preprocessor', function () {
})
})

it('adds .js extension and resolves with that output path when the originating file had been no javascript file', function () {
this.file.outputPath = 'output/output.ts'

return this.run().then((outputPath) => {
expect(outputPath).to.be.equal('output/output.ts.js')
})
})

it('emits "rerun" when shouldWatch is true and there is an update', function () {
this.file.shouldWatch = true
this.compilerApi.watch.yields(null, this.statsApi)
Expand Down