Answer the question
In order to leave comments, you need to log in
How to test GUI JavaScript in a browser from under the console?
Good time.
I've been sawing my project for a long time, the wysiwyg Jodit editor. By specifics, it is clear that the code interacts a lot with the browser. The project itself is written in TypeScript, which is compiled by webpack.
Webpack has the following settings:
output: {
path: path.join(__dirname, 'dist'),
filename: 'jodit.js',
publicPath: '/dist/',
libraryTarget: "this",
library: "Jodit"
},
it('Editor should replace and hide source textarea', function() {
var area = appendTestArea();
var editor = new Jodit(area);
expect(area.style.display).to.equal('none');
expect(editor.editor).to.equal(document.querySelector('.jodit_wysiwyg'));
})
var webpackConfig = require('./webpack.config');
var path = require('path');
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai'],
files: ['src/index.ts', 'test/bootstrap.js', 'test/**/*.js'],
reporters: ['progress'],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_INFO,
browsers: ['ChromeHeadless'],
autoWatch: false,
// singleRun: false, // Karma captures browsers, runs the tests and exits
concurrency: Infinity,
preprocessors: {
'src/index.ts': ['webpack'],
},
plugins: [
'karma-chrome-launcher',
'karma-mocha',
'karma-chai',
'karma-webpack',
'karma-sourcemap-loader'
],
webpack: {
devtool: 'eval-source-map',
module: webpackConfig.module,
resolve: webpackConfig.resolve,
},
webpackMiddleware: {
quiet: true,
noInfo:true,
publicPath: webpackConfig.output.publicPath
}
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question