Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module warning => message not throwing #753

Merged
merged 8 commits into from
Sep 25, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

env:
- TS_JEST_E2E_WORKDIR=/tmp/ts-jest-e2e-workdir
- TS_JEST_E2E_WORKDIR=/tmp/ts-jest-e2e-workdir TS_JEST_E2E_OPTIMIZATIONS=1

cache:
npm: true
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ install:
# - set CI=true
# Our E2E work dir
- set TS_JEST_E2E_WORKDIR=%APPDATA%\ts-jest-e2e
- set TS_JEST_E2E_OPTIMIZATIONS=1
- npm ci --ignore-scripts
- npm run clean -- --when-ci-commit-message

Expand Down
7 changes: 7 additions & 0 deletions e2e/__cases__/module-kinds/import-default.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import lib from './lib'

test('import default', () => {
expect(typeof lib).toBe('function')
expect(lib()).toBe('foo')
expect(lib.bar).toBe('bar')
})
7 changes: 7 additions & 0 deletions e2e/__cases__/module-kinds/import-legacy.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import lib = require('./lib')

test('import default', () => {
expect(typeof lib).toBe('function')
expect(lib()).toBe('foo')
expect(lib.bar).toBe('bar')
})
7 changes: 7 additions & 0 deletions e2e/__cases__/module-kinds/import-star.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as lib from './lib'

test('import default', () => {
expect(typeof lib).toBe('function')
expect(lib()).toBe('foo')
expect(lib.bar).toBe('bar')
})
5 changes: 5 additions & 0 deletions e2e/__cases__/module-kinds/lib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare function lib ()
declare namespace lib {
export const bar: string
}
export = lib
5 changes: 5 additions & 0 deletions e2e/__cases__/module-kinds/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function lib() { return 'foo' }

lib.bar = 'bar'

module.exports = lib
8 changes: 8 additions & 0 deletions e2e/__cases__/module-kinds/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"allowJs": true,
"rootDir": ".",
"outDir": "dist"
}
}
4 changes: 2 additions & 2 deletions e2e/__helpers__/test-case/__hooks-source__.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
const fs = require('fs')
const path = require('path')
const root = __dirname
const writeProcessIoTo = {{writeProcessIoTo}}
const writeProcessIoTo = path.resolve(root, {{writeProcessIoTo}})

exports.afterProcess = function (args, result) {
// const source = args[0]
const filePath = args[1]
const relPath = path.relative(root, filePath)
if (writeProcessIoTo && filePath.startsWith(`${root}${path.sep}`)) {
if (filePath.startsWith(`${root}${path.sep}`)) {
const dest = `${path.join(writeProcessIoTo, relPath)}.json`
const segments = relPath.split(path.sep)
segments.pop()
Expand Down
15 changes: 14 additions & 1 deletion e2e/__helpers__/test-case/run-descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export default class RunDescriptor {
}

get sourcePackageJson() {
try {
return this._sourcePackageJson || (this._sourcePackageJson = require(join(this.sourceDir, 'package.json')))
} catch (err) {}
return {}
}

get templateName(): string {
Expand All @@ -45,8 +48,18 @@ export default class RunDescriptor {
if (logUnlessStatus != null && logUnlessStatus !== result.status) {
// tslint:disable-next-line:no-console
console.log(
`Output of test run in "${this.name}" using template "${this.templateName}" (exit code: ${result.status}):\n\n`,
'='.repeat(70),
'\n',
`Test exited with unexpected status in "${this.name}" using template "${this.templateName}" (exit code: ${
result.status
}):\n`,
result.context.cmd,
result.context.args.join(' '),
'\n\n',
result.output.trim(),
'\n',
'='.repeat(70),
'\n',
)
}
return result
Expand Down
18 changes: 11 additions & 7 deletions e2e/__helpers__/test-case/run-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class RunResult {
args: string[]
env: { [key: string]: string }
config: jest.InitialOptions
digest: string
}>,
) {}
get logFilePath() {
Expand All @@ -44,26 +45,29 @@ export default class RunResult {
return this.result.status
}
get output() {
return stripAnsiColors(this.result.output ? this.result.output.join('\n\n') : '')
return this.normalize(stripAnsiColors(this.result.output ? this.result.output.join('\n\n') : ''))
}
get stderr() {
return stripAnsiColors((this.result.stderr || '').toString())
return this.normalize(stripAnsiColors((this.result.stderr || '').toString()))
}
get normalizedStderr() {
return normalizeJestOutput(this.stderr)
}
get stdout() {
return stripAnsiColors((this.result.stdout || '').toString())
return this.normalize(stripAnsiColors((this.result.stdout || '').toString()))
}
get normalizedStdout() {
return normalizeJestOutput(this.stdout)
}
get cmdLine() {
return this.normalize(
[this.context.cmd, ...this.context.args]
.filter(a => !['-u', '--updateSnapshot', '--runInBand', '--'].includes(a))
.join(' '),
const args = [this.context.cmd, ...this.context.args].filter(
a => !['-u', '--updateSnapshot', '--runInBand', '--'].includes(a),
)
const configIndex = args.indexOf('--config')
if (configIndex !== -1) {
args.splice(configIndex, 2)
}
return this.normalize(args.join(' '))
}

ioFor(relFilePath: string): ProcessedFileIo {
Expand Down