Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4ebe66c
make tests preprocessor agnostic
chrisbreiding Jul 14, 2020
26e6c87
update eslintignore
chrisbreiding Jul 14, 2020
a234881
put back deps needed for e2e test
chrisbreiding Jul 14, 2020
7a210b1
Merge branch 'develop' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 15, 2020
3c1e99f
remove obselete snapshot
chrisbreiding Jul 15, 2020
a2b0356
switch from browserify to webpack preprocessor
chrisbreiding Jul 15, 2020
00f58bf
cmon github
chrisbreiding Jul 15, 2020
99e32b8
fix/update tests
chrisbreiding Jul 15, 2020
5475b2d
bump preprocessor and update snapshots
chrisbreiding Jul 16, 2020
facc6ef
update snapshots
chrisbreiding Jul 16, 2020
73db7c5
bump preprocessor to gain json support
chrisbreiding Jul 16, 2020
205b7ec
fix e2e tests with webpack-originated errors
chrisbreiding Jul 17, 2020
eefd82c
bump preprocessor version, fix node globals
chrisbreiding Jul 17, 2020
ee5c144
update snapshot
chrisbreiding Jul 17, 2020
265d305
remove support for ? in file path
chrisbreiding Jul 17, 2020
b0d755d
Merge branch 'develop' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 17, 2020
6f1863b
bump preprocessor version
chrisbreiding Jul 20, 2020
9d8a8c3
bump preprocessor again
chrisbreiding Jul 20, 2020
ec71582
bump preprocessor
chrisbreiding Jul 20, 2020
155821a
Merge branch 'develop' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 21, 2020
4e7840f
bump preprocessor
chrisbreiding Jul 21, 2020
e83571b
Merge branch 'develop' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 21, 2020
a0bc387
update snapshots
chrisbreiding Jul 21, 2020
b943176
bump preprocessor version
chrisbreiding Jul 23, 2020
86530af
bump preprocessor, quiet the paths plugin
chrisbreiding Jul 23, 2020
b0404f3
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 23, 2020
8c265ee
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 23, 2020
d212b0a
add test verifying tsconfig paths work
chrisbreiding Jul 23, 2020
03bd4eb
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
chrisbreiding Jul 27, 2020
31992e2
refactor registering ts-node
chrisbreiding Jul 31, 2020
32dd549
separate spec/support file typescript tests from plugins file typescr…
chrisbreiding Jul 31, 2020
8d95773
fix unit tests
chrisbreiding Jul 31, 2020
55e97a1
fix: Remove esModuleInterop default from ts-node (#7808)
sainthkh Aug 3, 2020
e2a8b5c
clean up e2e project
chrisbreiding Aug 3, 2020
664d8c4
bump preprocessor to 1.3.2, which removes esModuleInterop default value
chrisbreiding Aug 3, 2020
17f3926
improve esmoduleinterop e2e tests
chrisbreiding Aug 7, 2020
c4bdc04
change spec file
chrisbreiding Aug 7, 2020
61f5099
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
chrisbreiding Aug 10, 2020
c54eaac
bump batteries-included preprocessor and install latest webpack prepr…
chrisbreiding Aug 10, 2020
f1bcfb9
update snapshots
chrisbreiding Aug 10, 2020
1ff1150
put back snapshot
chrisbreiding Aug 10, 2020
d6248a7
update snapshot
chrisbreiding Aug 10, 2020
cfe5395
update snapshot
chrisbreiding Aug 10, 2020
3837ccd
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
chrisbreiding Aug 10, 2020
80ee0f7
Merge branch 'v5.0-release' into tr-49-default-preprocessor-webpack
brian-mann Aug 10, 2020
60d32f4
Merge branch 'tr-49-default-preprocessor-webpack' into tr-132-change-…
brian-mann Aug 10, 2020
752a921
Merge branch 'v5.0-release' into tr-132-change-esmodule-interop-default
brian-mann Aug 10, 2020
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ packages/server/lib/scaffold/plugins/index.js
packages/server/lib/scaffold/support/index.js
packages/server/lib/scaffold/support/commands.js
packages/server/test/support/fixtures/projects/e2e/cypress/integration/stdout_exit_early_failing_spec.js
packages/server/test/support/fixtures/projects/e2e/cypress/integration/typescript_failing_spec.ts
packages/server/test/support/fixtures/projects/e2e/cypress/integration/typescript_syntax_error_spec.ts

**/.projects
**/*.d.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['e2e typescript spec passes 1'] = `
exports['e2e typescript in spec and support file spec passes 1'] = `

====================================================================================================

Expand Down Expand Up @@ -62,7 +62,7 @@ exports['e2e typescript spec passes 1'] = `

`

exports['e2e typescript spec fails 1'] = `
exports['e2e typescript in spec and support file spec fails with syntax error 1'] = `

====================================================================================================

Expand All @@ -71,23 +71,23 @@ exports['e2e typescript spec fails 1'] = `
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (typescript_failing_spec.ts)
│ Searched: cypress/integration/typescript_failing_spec.ts
│ Specs: 1 found (typescript_syntax_error_spec.ts) │
│ Searched: cypress/integration/typescript_syntax_error_spec.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: typescript_failing_spec.ts (1 of 1)
Running: typescript_syntax_error_spec.ts (1 of 1)

Oops...we found an error preparing this test file:

/foo/bar/.projects/e2e/cypress/integration/typescript_failing_spec.ts
/foo/bar/.projects/e2e/cypress/integration/typescript_syntax_error_spec.ts

The error was:

Error: Webpack Compilation Error
./cypress/integration/typescript_failing_spec.tsXX:XX
./cypress/integration/typescript_syntax_error_spec.tsXX:XX
Module parse failed: Unexpected token (4:19)
File was processed with these loaders:
* ../../../../node_modules/@cypress/webpack-batteries-included-preprocessor/node_modules/ts-loader/index.js
Expand Down Expand Up @@ -115,14 +115,15 @@ Fix the error in your code and re-run your tests.
│ Screenshots: 0 │
│ Video: true │
│ Duration: X seconds │
│ Spec Ran: typescript_failing_spec.ts
│ Spec Ran: typescript_syntax_error_spec.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Video)

- Started processing: Compressing to 32 CRF
- Finished processing: /XXX/XXX/XXX/cypress/videos/typescript_failing_spec.ts.mp4 (X second)
- Finished processing: /XXX/XXX/XXX/cypress/videos/typescript_syntax_error_spec.ts (X second)
.mp4


====================================================================================================
Expand All @@ -132,14 +133,14 @@ Fix the error in your code and re-run your tests.

Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ typescript_failing_spec.ts XX:XX - - 1 - - │
│ ✖ typescript_syntax_error_spec.ts XX:XX - - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) XX:XX - - 1 - -


`

exports['e2e typescript project passes 1'] = `
exports['e2e typescript in spec and support file project passes 1'] = `

====================================================================================================

Expand Down Expand Up @@ -227,20 +228,3 @@ exports['e2e typescript project passes 1'] = `


`

exports['typescript with tsconfig run'] = `
(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ app_spec.ts XX:XX 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✔ js-spec.js XX:XX 2 2 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✔ math.ts XX:XX - - - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 3 3 - - -


`
20 changes: 2 additions & 18 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
const _ = require('lodash')
const debug = require('debug')('cypress:server:plugins:child')
const Promise = require('bluebird')
const tsnode = require('ts-node')
const resolve = require('resolve')

const errors = require('../../errors')
const preprocessor = require('./preprocessor')
const task = require('./task')
const util = require('../util')
const validateEvent = require('./validate_event')
const tsNodeOptions = require('../../util/ts-node-options')
const { registerTsNode } = require('../../util/ts-node')

const ARRAY_METHODS = ['concat', 'push', 'unshift', 'slice', 'pop', 'shift', 'slice', 'splice', 'filter', 'map', 'forEach', 'reduce', 'reverse', 'splice', 'includes']

Expand Down Expand Up @@ -183,21 +181,7 @@ module.exports = (ipc, pluginsFile, projectRoot) => {
})

if (!tsRegistered) {
try {
const tsPath = resolve.sync('typescript', {
basedir: projectRoot,
})

const tsOptions = tsNodeOptions.getTsNodeOptions(tsPath)

debug('typescript path: %s', tsPath)
debug('registering plugins TS with options %o', tsOptions)

tsnode.register(tsOptions)
} catch (e) {
debug(`typescript doesn't exist. ts-node setup failed.`)
debug('error message: %s', e.message)
}
registerTsNode(projectRoot)

// ensure typescript is only registered once
tsRegistered = true
Expand Down
20 changes: 2 additions & 18 deletions packages/server/lib/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const Promise = require('bluebird')
const commitInfo = require('@cypress/commit-info')
const la = require('lazy-ass')
const check = require('check-more-types')
const tsnode = require('ts-node')
const resolve = require('resolve')
const scaffoldDebug = require('debug')('cypress:server:scaffold')
const debug = require('debug')('cypress:server:project')
const cwd = require('./cwd')
Expand All @@ -31,7 +29,7 @@ const keys = require('./util/keys')
const settings = require('./util/settings')
const specsUtil = require('./util/specs')
const { escapeFilenameInUrl } = require('./util/escape_filename')
const tsNodeOptions = require('./util/ts-node-options')
const { registerTsNode } = require('./util/ts-node')

const localCwd = cwd()

Expand Down Expand Up @@ -103,21 +101,7 @@ class Project extends EE {
return scaffold.plugins(path.dirname(cfg.pluginsFile), cfg)
}
}).then((cfg) => {
try {
const tsPath = resolve.sync('typescript', {
basedir: this.projectRoot,
})

const tsOptions = tsNodeOptions.getTsNodeOptions(tsPath)

debug('typescript path: %s', tsPath)
debug('registering project TS with options %o', tsOptions)

tsnode.register(tsOptions)
} catch (e) {
debug(`typescript doesn't exist. ts-node setup failed.`)
debug('error message %s', e.message)
}
registerTsNode(this.projectRoot)

return cfg
}).then((cfg) => {
Expand Down
29 changes: 0 additions & 29 deletions packages/server/lib/util/ts-node-options.js

This file was deleted.

34 changes: 34 additions & 0 deletions packages/server/lib/util/ts-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const debug = require('debug')('cypress:server:ts-node')
const tsnode = require('ts-node')
const resolve = require('resolve')

const getTsNodeOptions = (tsPath) => {
return {
compiler: tsPath, // use the user's installed typescript
compilerOptions: {
module: 'CommonJS',
},
transpileOnly: true, // transpile only (no type-check) for speed
}
}

const registerTsNode = (projectRoot) => {
try {
const tsPath = resolve.sync('typescript', {
basedir: projectRoot,
})
const tsOptions = getTsNodeOptions(tsPath)

debug('typescript path: %s', tsPath)
debug('registering project TS with options %o', tsOptions)

tsnode.register(tsOptions)
} catch (err) {
debug(`typescript doesn't exist. ts-node setup failed.`)
debug('error message: %s', err.message)
}
}

module.exports = {
registerTsNode,
}
26 changes: 26 additions & 0 deletions packages/server/test/e2e/1_typescript_plugins_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import e2e from '../support/helpers/e2e'
import Fixtures from '../support/helpers/fixtures'

describe('e2e typescript in plugins file', function () {
e2e.setup()

it('handles tsconfig with module other than commonjs', function () {
return e2e.exec(this, {
project: Fixtures.projectPath('ts-proj-with-module-esnext'),
})
})

// https://github.com/cypress-io/cypress/issues/7575
it('defaults to esModuleInterop: false', function () {
return e2e.exec(this, {
project: Fixtures.projectPath('ts-proj'),
})
})

// https://github.com/cypress-io/cypress/issues/7575
it('allows esModuleInterop to be overridden with true via tsconfig.json', function () {
return e2e.exec(this, {
project: Fixtures.projectPath('ts-proj-esmoduleinterop-true'),
})
})
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import snapshot from 'snap-shot-it'

import e2e from '../support/helpers/e2e'
import Fixtures from '../support/helpers/fixtures'

describe('e2e typescript', function () {
describe('e2e typescript in spec and support file', function () {
e2e.setup()

it('spec passes', function () {
Expand All @@ -13,9 +11,9 @@ describe('e2e typescript', function () {
})
})

it('spec fails', function () {
it('spec fails with syntax error', function () {
return e2e.exec(this, {
spec: 'typescript_failing_spec.ts',
spec: 'typescript_syntax_error_spec.ts',
snapshot: true,
expectedExitCode: 1,
onStdout: e2e.normalizeWebpackErrors,
Expand All @@ -36,19 +34,4 @@ describe('e2e typescript', function () {
project: Fixtures.projectPath('ts-proj-with-paths'),
})
})

it('handles tsconfig with module other than commonjs', function () {
const projPath = Fixtures.projectPath('ts-proj-with-own-tsconfig')

return e2e.exec(this, {
project: projPath,
config: {
video: false,
},
}).then((result) => {
const runSummary = e2e.leaveRunFinishedTable(e2e.normalizeStdout(result.stdout))

snapshot('typescript with tsconfig run', runSummary)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"supportFile": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it('passes', () => {
expect(true).to.be.true
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.export1 = 'export1'

exports.export2 = 'export2'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="cypress" />

import commonjsExports from './commonjs-export'

if (commonjsExports.export1 !== 'export1' || commonjsExports.export2 !== 'export2') {
throw new Error('Imported values do not match exported values')
}

// Default Cypress plugin function
export default (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) => {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"supportFolder": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('uses task that is in typescript plugins file', () => {
it('calls task', () => {
cy.task('hello', 'TS').should('equal', 'Hello, TS!')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const asyncGreeting = async (greeting: string) => {
return Promise.resolve(`Hello, ${greeting}!`)
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading