diff --git a/.gitignore b/.gitignore index 45ba7140..65583278 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ data/themes/gadjo/static/css/agent-portal.css.map .cache .coverage .pytest_cache/ +node_modules/ +coverage/ +package.json +package-lock.json diff --git a/Jenkinsfile b/Jenkinsfile index 14738261..14228b4c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { always { script { utils = new Utils() - utils.publish_coverage('coverage.xml') + utils.publish_coverage('coverage.xml,coverage/cobertura-coverage.xml') utils.publish_coverage_native('index.html') utils.publish_pylint('pylint.out') } diff --git a/setup-vitest.sh b/setup-vitest.sh new file mode 100644 index 00000000..3602367b --- /dev/null +++ b/setup-vitest.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +pip install $* +nodeenv --prebuilt --python-virtualenv +source $VIRTUAL_ENV/bin/activate # source again to activate npm from env +npm install vite vitest happy-dom @vitest/coverage-v8 diff --git a/stats b/stats new file mode 100644 index 00000000..a05b3b79 Binary files /dev/null and b/stats differ diff --git a/tests/js/dummy.test.js b/tests/js/dummy.test.js new file mode 100644 index 00000000..7316a07f --- /dev/null +++ b/tests/js/dummy.test.js @@ -0,0 +1,5 @@ +import { expect, test, vi} from 'vitest' + +test('dummy test', async () => { + expect(true).toBe(true) +}) diff --git a/tox.ini b/tox.ini index 1a13965a..a57e1e00 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/combo/{env:BRANCH_NAME:} -envlist = coverage-py3-django32-codestyle, pylint +envlist = coverage-py3-django32-codestyle, pylint, vitest [testenv] usedevelop = True @@ -81,3 +81,13 @@ allowlist_externals = commands = ./getlasso3.sh ./pylint.sh combo/ tests/ + +[testenv:vitest] +deps = nodeenv +allowlist_externals = + bash + npx +install_command = bash setup-vitest.sh {packages} +setenv = + NODE_PATH={envdir}/lib/node_modules +commands = npx vitest --run --coverage diff --git a/vitest.config.js b/vitest.config.js new file mode 100644 index 00000000..2a60ab3f --- /dev/null +++ b/vitest.config.js @@ -0,0 +1,16 @@ +import { fileURLToPath, URL } from 'node:url' +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + include: 'tests/js/**/*.test.js', + watchExclude: ['**'], + coverage: { + include: ['combo/**/*.js'], + all: true, + reporter: ['cobertura', 'html'], + }, + environment: 'happy-dom' + } +}) +