Skip to content

Commit

Permalink
Merge pull request #6 from conestack/web-test-runner
Browse files Browse the repository at this point in the history
Web test runner
  • Loading branch information
rnixx authored Feb 6, 2024
2 parents e1593e9 + cd405b6 commit 019dbfc
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 113 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Test treibstoff
name: Tests

on:
push:
on: [push]

jobs:
test:
Expand All @@ -10,12 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install
run: |
make install
- name: Run tests
run: |
make karma
make wtr
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
*.egg-info/
*.pyc
/.mxmake/
/bin/
/build/
/bundle/
/constraints-mxdev.txt
/coverage/
/dist/
/docs/html/
/include/
/karma/
/lib/
/lib64
/node_modules/
/package-lock.json
/pyvenv.cfg
/requirements-mxdev.txt
/share/
/treibstoff-*.tgz
/treibstoff.egg-info/
/venv/
10 changes: 2 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@
/MANIFEST.in
/Makefile
/TODO.rst
/bin/
/build/
/dist/
/docs/
/include/
/karma/
/lib/
/lib64
/coverage/
/mx.ini
/node_modules/
/pyvenv.cfg
/requirements-mxdev.txt
/rollup.conf.js
/scripts/
/setup.cfg
/setup.py
/share/
/treibstoff-*.tgz
/treibstoff.egg-info/
/treibstoff/
/venv/
/venv/
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changes
0.4.0 (unreleased)
------------------

- Use web test runner instead of deprecated karma.
[rnix]

- Deprecate usage of ``ts.ajax.request``. ``ts.http_request`` shall be used
instead.
[rnix]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
License
=======

Copyright (c) 2021-2023, Conestack Contributors
Copyright (c) 2021-2024, Conestack Contributors

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
56 changes: 27 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#: core.packages
#: docs.jsdoc
#: docs.sphinx
#: js.karma
#: js.npm
#: js.rollup
#: js.wtr
#: system.dependencies
#
# SETTINGS (ALL CHANGES MADE BELOW SETTINGS WILL BE LOST)
Expand All @@ -31,7 +31,7 @@ RUN_TARGET?=
CLEAN_FS?=build \
bundle \
dist \
karma \
coverage \
treibstoff-* \
treibstoff.egg-info

Expand All @@ -54,7 +54,7 @@ NPM_PACKAGES?=
# No default value.
NPM_DEV_PACKAGES?=\
qunit \
karma-qunit \
web-test-runner-qunit \
git://github.com/jquery/jquery.git\#2b6b5e0a3ba3029ec3ad1525a178920765e3adf1

# Packages which get installed with `--save-prod` option.
Expand All @@ -76,22 +76,22 @@ NPM_INSTALL_OPTS?=
# No default value.
SYSTEM_DEPENDENCIES?=

## js.wtr

# Web test runner config file.
# Default: wtr.config.mjs
WTR_CONFIG?=wtr.config.mjs

# Web test runner additional command line options.
# Default: --coverage
WTR_OPTIONS?=--coverage

## js.rollup

# Rollup config file.
# Default: rollup.conf.js
ROLLUP_CONFIG?=rollup.conf.js

## js.karma

# Karma config file.
# Default: karma.conf.js
KARMA_CONFIG?=karma.conf.js

# Karma additional command line options.
# Default: --single-run
KARMA_OPTIONS?=--single-run

## core.mxenv

# Python interpreter to use.
Expand Down Expand Up @@ -240,33 +240,31 @@ system-dependencies:
|| sudo apt-get install -y $(SYSTEM_DEPENDENCIES)

##############################################################################
# rollup
# web test runner
##############################################################################

# extend npm dev packages
NPM_DEV_PACKAGES+=\
rollup \
rollup-plugin-cleanup \
@rollup/plugin-terser
@web/test-runner \
@web/dev-server-import-maps

.PHONY: rollup
rollup: $(NPM_TARGET)
@$(NPM_PREFIX)/node_modules/.bin/rollup --config $(ROLLUP_CONFIG)
.PHONY: wtr
wtr: $(NPM_TARGET)
@$(NPM_PREFIX)/node_modules/.bin/web-test-runner $(WTR_OPTIONS) --config $(WTR_CONFIG)

##############################################################################
# karma
# rollup
##############################################################################

# extend npm dev packages
NPM_DEV_PACKAGES+=\
karma \
karma-coverage \
karma-chrome-launcher \
karma-module-resolver-preprocessor
rollup \
rollup-plugin-cleanup \
@rollup/plugin-terser

.PHONY: karma
karma: $(NPM_TARGET)
@$(NPM_PREFIX)/node_modules/.bin/karma start $(KARMA_CONFIG) $(KARMA_OPTIONS)
.PHONY: rollup
rollup: $(NPM_TARGET)
@$(NPM_PREFIX)/node_modules/.bin/rollup --config $(ROLLUP_CONFIG)

##############################################################################
# jsdoc
Expand All @@ -282,7 +280,7 @@ $(JSDOC_TARGET): $(NPM_TARGET)

.PHONY: jsdoc
jsdoc: $(JSDOC_TARGET)
@export PATH=$PATH:$(JSDOC_PATH)
@export PATH=$(PATH):$(JSDOC_PATH)

# extend npm dev packages
NPM_DEV_PACKAGES+=jsdoc
Expand Down
12 changes: 6 additions & 6 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ Install development environment:

.. code-block:: sh
./scripts/install.sh
make install
Cleanup development environment:

.. code-block:: sh
./scripts/clean.sh
make clean
Run tests:

.. code-block:: sh
./scripts/karma.sh
make wtr
To view coverage report, open in browser::

karma/coverage/[browser name]/index.html
coverage/lcov-report/index.html

Create Javascript bundles:

.. code-block:: sh
./scripts/rollup.sh
make rollup
Automatically build JS bundles while development:

Expand All @@ -56,4 +56,4 @@ Build documentation:

.. code-block:: sh
./scripts/docs.sh
make docs
51 changes: 0 additions & 51 deletions karma.conf.js

This file was deleted.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
"main": "src/treibstoff.js",
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@web/dev-server-import-maps": "^0.2.0",
"@web/test-runner": "^0.18.0",
"install": "^0.13.0",
"jquery": "github:jquery/jquery#2b6b5e0a3ba3029ec3ad1525a178920765e3adf1",
"jsdoc": "^3.6.11",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.2.0",
"karma-coverage": "^2.2.1",
"karma-module-resolver-preprocessor": "^1.1.3",
"karma-qunit": "^4.1.2",
"qunit": "^2.20.0",
"rollup": "^2.79.1",
"rollup-plugin-cleanup": "^3.2.1"
"rollup-plugin-cleanup": "^3.2.1",
"web-test-runner-qunit": "^1.0.0"
}
}
25 changes: 25 additions & 0 deletions wtr.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {importMapsPlugin} from '@web/dev-server-import-maps';

export default {
nodeResolve: true,
testFramework: {
path: './node_modules/web-test-runner-qunit/dist/autorun.js',
config: {
noglobals: false
}
},
files: [
'tests/**/test_*.js'
],
plugins: [
importMapsPlugin({
inject: {
importMap: {
imports: {
'jquery': './node_modules/jquery/src/jquery.js'
},
},
},
}),
],
}

0 comments on commit 019dbfc

Please sign in to comment.