Last active
July 24, 2019 08:17
-
-
Save mizchi/163127ef88d3f45ec11d332ad13a9edc to your computer and use it in GitHub Desktop.
karma + webpack + typescript settings
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
<script> | |
it("ok in html", (done) => { | |
done() | |
}); | |
</script> | |
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
// @ts-ignore | |
it("ok in 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
const webpack = require("webpack"); | |
const isCI = !!process.env.CI; | |
module.exports = config => { | |
config.set({ | |
browserStack: { | |
// your config | |
}, | |
customLaunchers: { | |
bs_ie_11: { | |
base: "BrowserStack", | |
browser: "IE", | |
browser_version: "11.0", | |
os: "Windows", | |
os_version: "10" | |
}, | |
}, | |
browsers: isCI | |
? ["bs_ie_11"] | |
: ["ChromeHeadless"], | |
frameworks: ["mocha"], | |
singleRun: true, | |
files: ["foo_test.ts", "bar_test.html"], | |
preprocessors: { "*_test.ts": ["webpack"] }, | |
webpack: { | |
mode: process.env.WEBPACK_MODE || "production", | |
resolve: { | |
extensions: [".js", ".mjs", ".ts", ".tsx"] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
use: [ | |
{ | |
loader: "ts-loader", | |
options: { | |
transpileOnly: true | |
} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.DefinePlugin({ | |
"process.env": { | |
CI: JSON.stringify(process.env.CI) | |
} | |
}) | |
] | |
}, | |
reporters: ["mocha"], | |
colors: true, | |
logLevel: config.LOG_INFO | |
}); | |
}; |
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
{ | |
"name": "test", | |
"private": true, | |
"version": "1.0.0", | |
"license": "MIT", | |
"devDependencies": { | |
"@types/mocha": "^5.2.7", | |
"karma": "4.2.0", | |
"karma-browserstack-launcher": "1.5.1", | |
"karma-chrome-launcher": "3.0.0", | |
"karma-mocha": "1.3.0", | |
"karma-mocha-reporter": "2.2.5", | |
"karma-webpack": "4.0.2", | |
"mocha": "^6.2.0", | |
"ts-loader": "^6.0.4", | |
"typescript": "^3.5.3", | |
"webpack": "^4.37.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment