0.0.20 • Published 2 years ago

kiwi-webpack-plugin v0.0.20

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

Kiwi - Javascript Test Runner for Kakoune

Warning: This tool is under development. Breaking changes make occur anytime and some functionality might not be well tested. Do not rely on it for anything other than experiments.

Supports only Webpack 4 not 5

demo

Getting Started Guide

(if using the chrome runner) A recent Google Chrome browser should be installed

Version 12 or greater of NodeJS should be installed

The Kakoune Editor should be installed

Python and Virtualenv should be installed (only needed for review app)

# A new webpack app
mkdir app1
cd app1
mkdir src
npm init

# Install the plugin and related dependencies
npm i kiwi-webpack-plugin webpack@4 webpack-cli webpack-dev-server chai

create webpack.config.js

const KiwiPlugin = require('kiwi-webpack-plugin');

module.exports = {
    entry: './src/index.js',
    
    // target: 'node',    // use this if using the 'node' runner
    
    // Enable source maps
    devtool: 'source-map',
    
    plugins: [
        new KiwiPlugin({
        	testEntry: './src/tests.js',
        	// Run the chrome browser instance in headless mode (in background without window)
        	headless: true,
        	// when building once (not watching) do process.exit(1)
        	// if any tests failed
        	stopBuildOnFail: true,
        	runner: 'chrome', // can also be 'node'
    	}),
    ],
}

create src/index.js

export function someFunction() {
	return 1234;
};

create src/tests.js

import { expect } from 'chai';
import { someFunction } from './index';

describe('Test Module', () => {
   it('test addition', () => {
       expect(1233 + 1).to.equal(someFunction());
   });
});

add to package.json

"scripts": {
    "start": "webpack-dev-server -w"
},

finally, run

npm start

and in another shell tab open src/tests.js in Kakoune

kak src/tests.js

Usage with Typescript

Install types - only the "describe" and "it" jasmine-like globals are supported

npm i @types/jasmine @types/chai

add to tsconfig.json

{
  "compilerOptions": {
  	"sourceMap": true
  	
  	...

Usage with HtmlWebpackPlugin

Add excludeChunks: ['kiwi-tests'] like so:

{
    plugins: [
        new HtmlWebpackPlugin({
            title: 'App',
            excludeChunks: ['kiwi-tests'],
        }),
        new KiwiPlugin({ testEntry: './src/tests.js', headless: true }),
    ],
}

Developing the library

Run npm start.

Run an example in the examples dir.

or for console.log debugging:

add console.log(1) in a source file

Kakoune Interface Tests

Replace kakoune_interface_tests with the test file of choice if needed.

npm i; npm start
# In another shell session
npm i -g nodemon
nodemon dist/kakoune_interface_tests.js
# or
nodemon dist/unit_tests.js

Using Kakoune Interface Tests:

edit src/kakoune_interface_tests.ts

The test file itself is used to display interface items

Unit Tests

# Build the minimal example with source maps
(cd examples/minimal && npm i && npm run build)

npm i
npm test
0.0.20

2 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago