-
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added speculative test of allowJsImportTypes scenario (should initial…
…ly fail until fix is applied) (#590) * Added speculative test of allowJsImportTypes scenario * correct test to reference entry * added noEmitOnError to trigger error * no longer depends on @types/jasmine so can be made to run back with 1.8.2 * go for a 1.8.2 friendly tsconfig.json * Resolved filenames that are definition file from node_modules are treated as isExternalLibraryImport Suggested by @bsouthga - let's see if this fixes our broken test. * match backslashes or forward slashes * Just run test against 2.1+
- Loading branch information
1 parent
beaa2b2
commit 1b33393
Showing
10 changed files
with
158 additions
and
1 deletion.
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
3 changes: 3 additions & 0 deletions
3
test/execution-tests/2.1.4_babel-allowJsImportTypes/README.md
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,3 @@ | ||
This test confirms that you can import typings from an npm module when `allowJs` is true. See details [#586](https://github.com/TypeStrong/ts-loader/issues/586). | ||
|
||
This test is roughly based on https://github.com/bsouthga/ts-loader-types-error-example |
51 changes: 51 additions & 0 deletions
51
test/execution-tests/2.1.4_babel-allowJsImportTypes/karma.conf.js
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 @@ | ||
/* eslint-disable no-var, strict */ | ||
'use strict'; | ||
var webpackConfig = require('./webpack.config.js'); | ||
|
||
module.exports = function(config) { | ||
// Documentation: https://karma-runner.github.io/0.13/config/configuration-file.html | ||
config.set({ | ||
browsers: [ 'PhantomJS' ], | ||
|
||
files: [ | ||
// This ensures we have the es6 shims in place and then loads all the tests | ||
'main.js' | ||
], | ||
|
||
port: 9876, | ||
|
||
frameworks: [ 'jasmine' ], | ||
|
||
logLevel: config.LOG_INFO, //config.LOG_DEBUG | ||
|
||
preprocessors: { | ||
'main.js': [ 'webpack', 'sourcemap' ] | ||
}, | ||
|
||
webpack: { | ||
devtool: 'inline-source-map', | ||
module: webpackConfig.module, | ||
resolve: webpackConfig.resolve, | ||
|
||
// for test harness purposes only, you would not need this in a normal project | ||
resolveLoader: webpackConfig.resolveLoader | ||
}, | ||
|
||
webpackMiddleware: { | ||
quiet: true, | ||
stats: { | ||
colors: true | ||
} | ||
}, | ||
|
||
// reporter options | ||
mochaReporter: { | ||
colors: { | ||
success: 'bgGreen', | ||
info: 'cyan', | ||
warning: 'bgBlue', | ||
error: 'bgRed' | ||
} | ||
} | ||
}); | ||
}; |
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 @@ | ||
import 'babel-polyfill'; | ||
|
||
const testsContext = require.context('./', true, /\.tests\.js$/); | ||
testsContext.keys().forEach(testsContext); |
16 changes: 16 additions & 0 deletions
16
test/execution-tests/2.1.4_babel-allowJsImportTypes/package.json
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,16 @@ | ||
{ | ||
"name": "allow-js-import-types", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"devDependencies": { | ||
"babel": "^6.0.0", | ||
"babel-core": "^6.0.0", | ||
"babel-loader": "^7.0.0", | ||
"babel-preset-es2015": "^6.0.0", | ||
"jasmine-core": "^2.3.4" | ||
}, | ||
"dependencies": { | ||
"babel-polyfill": "^6.0.0", | ||
"event-rank": "^0.0.10" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
test/execution-tests/2.1.4_babel-allowJsImportTypes/src/entry.js
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,5 @@ | ||
import EventRank from './imported'; | ||
|
||
export function getEventRank() { | ||
return EventRank; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/execution-tests/2.1.4_babel-allowJsImportTypes/src/imported.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { EventRank } from 'event-rank'; | ||
|
||
export default EventRank; |
8 changes: 8 additions & 0 deletions
8
test/execution-tests/2.1.4_babel-allowJsImportTypes/test/entry.tests.js
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,8 @@ | ||
var entry = require('../src/entry'); | ||
|
||
describe("entry", function() { | ||
it("getEventRank produces something", function() { | ||
var EventRank = entry.getEventRank(); | ||
expect(EventRank).not.toBeUndefined(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
test/execution-tests/2.1.4_babel-allowJsImportTypes/tsconfig.json
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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noImplicitAny": false, | ||
"sourceMap": true, | ||
"target": "es2015" | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
test/execution-tests/2.1.4_babel-allowJsImportTypes/webpack.config.js
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,55 @@ | ||
/* eslint-disable no-var, strict, prefer-arrow-callback */ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
var babelOptions = { | ||
"presets": [ | ||
[ | ||
"es2015", | ||
{ | ||
"modules": false | ||
} | ||
] | ||
] | ||
}; | ||
|
||
module.exports = { | ||
entry: './src/entry.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
rules: [{ | ||
test: /\.ts(x?)$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: babelOptions | ||
}, | ||
{ | ||
loader: 'ts-loader', | ||
options: { entryFileIsJs: true } | ||
} | ||
] | ||
}, { | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: babelOptions | ||
} | ||
] | ||
}] | ||
}, | ||
resolve: { | ||
// Add `.ts` and `.tsx` as a resolvable extension. | ||
extensions: ['.ts', '.tsx', '.js'] | ||
}, | ||
}; | ||
|
||
// for test harness purposes only, you would not need this in a normal project | ||
module.exports.resolveLoader = { alias: { 'ts-loader': path.join(__dirname, "../../../index.js") } } |