-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add CI integration for karma/jasmine test harness for React components
- Loading branch information
1 parent
cc4368f
commit 64f8a8c
Showing
11 changed files
with
179 additions
and
12 deletions.
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
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
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
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,130 @@ | ||
const Path = require( "path" ); | ||
const os = require("os"); | ||
var webpack = require('webpack'); | ||
|
||
console.log("resolved dirname") | ||
console.log(Path.resolve(__dirname, './.config/webpack/webpack.config.ts')); | ||
|
||
module.exports = function( config ) { | ||
config.set( { | ||
frameworks: [ | ||
"jasmine", | ||
"webpack", | ||
], | ||
client: { | ||
jasmine: { | ||
random: false | ||
} | ||
}, | ||
files: ['test/react/webpack.tests.js'], | ||
preprocessors: { | ||
"test/react/webpack.tests.js": ["webpack", "sourcemap"], | ||
}, | ||
webpack: { | ||
mode: "development", | ||
devtool: 'inline-source-map', // sourcemap support | ||
output: { | ||
filename: '[name].js', | ||
path: Path.join(__dirname, 'test/dist/_karma_webpack_') + Math.floor(Math.random() * 1000000), | ||
}, | ||
externals: [ | ||
'emotion', | ||
'@emotion/react', | ||
'@emotion/css', | ||
'@grafana/runtime', | ||
'@grafana/slate-react', | ||
'react-redux', | ||
'redux', | ||
'react-router', | ||
'react-router-dom', | ||
'd3', | ||
'slate', | ||
'slate-plain-serializer', | ||
'prismjs', | ||
'@grafana/ui', | ||
'jquery', | ||
'moment', | ||
'lodash', | ||
'rxjs', | ||
'angular', | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /src\/(?:.*\/)?module\.tsx?$/, | ||
use: [ | ||
{ | ||
loader: 'imports-loader', | ||
options: { | ||
imports: `side-effects grafana-public-path`, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
exclude: /(node_modules)/, | ||
test: /\.[tj]sx?$/, | ||
use: { | ||
loader: 'swc-loader', | ||
options: { | ||
jsc: { | ||
baseUrl: Path.resolve(process.cwd(), "./src"), | ||
target: 'es2015', | ||
loose: false, | ||
parser: { | ||
syntax: 'typescript', | ||
tsx: true, | ||
decorators: false, | ||
dynamicImport: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
// handle resolving "rootDir" paths | ||
modules: [Path.resolve(process.cwd(), 'src'), 'node_modules'], | ||
fallback: { | ||
"fs": false, | ||
"util": false, | ||
"stream": false, | ||
"tty": require.resolve("tty-browserify"), | ||
} | ||
}, | ||
stats: { | ||
modules: false, | ||
colors: true, | ||
}, | ||
watch: false, | ||
optimization: { | ||
runtimeChunk: 'single', | ||
splitChunks: { | ||
chunks: 'all', | ||
minSize: 0, | ||
cacheGroups: { | ||
commons: { | ||
name: 'commons', | ||
chunks: 'initial', | ||
minChunks: 1, | ||
}, | ||
}, | ||
}, | ||
} | ||
}, | ||
client: { | ||
captureConsole: true, | ||
}, | ||
reporters: ['dots'], | ||
exclude: [ | ||
"src/components/lib/leaflet.js", | ||
"src/components/old/*" | ||
], | ||
browsers: ["ChromeHeadless"], | ||
singleRun: true, | ||
webpackMiddleware: { noInfo: true }, | ||
browserNoActivityTimeout: 60000 // 60s; wait for webpack to compile :-( | ||
} ); | ||
}; |
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
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { MapCanvas } from './components/MapCanvas.component.js'; | ||
import { PubSub } from './components/lib/pubsub.js'; | ||
import { signals } from './signals.js'; | ||
import { CustomTextArea } from './components/CustomTextArea'; | ||
|
||
export { MapCanvas }; | ||
export { PubSub }; | ||
export { signals }; | ||
export { signals }; | ||
export { CustomTextArea }; |
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 @@ | ||
This folder will be used to store webpack build files for tests. Committed this readme to ensure it is created. |
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 @@ | ||
console.log("loaded the customTextArea test"); |
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
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,25 @@ | ||
// low-key polyfill for process | ||
window.process = { | ||
env: { DEBUG: true }, | ||
stderr: { fd: 1 }, | ||
} | ||
|
||
const { MapCanvas, PubSub, signals, CustomTextArea } = require("../../src/exports.ts"); | ||
|
||
const React = require("react"); | ||
|
||
const ReactDOM = require("react-dom/client"); | ||
|
||
const rootElem = document.createElement("div"); | ||
|
||
document.body.appendChild(rootElem); | ||
|
||
const root = ReactDOM.createRoot(rootElem); | ||
|
||
const props = { | ||
item: { settings: { useTextArea: true } } | ||
}; | ||
|
||
root.render(React.createElement(CustomTextArea, props)); | ||
|
||
console.log(document.getElementsByTagName("textarea")) |