js: configure unit tests (#83453)
gitea/combo/pipeline/head This commit looks good Details

This commit is contained in:
Corentin Sechet 2023-11-24 08:46:07 +01:00 committed by Corentin Sechet
parent 9b491b824f
commit dd877aad7c
7 changed files with 43 additions and 2 deletions

4
.gitignore vendored
View File

@ -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

2
Jenkinsfile vendored
View File

@ -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')
}

6
setup-vitest.sh Normal file
View File

@ -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

BIN
stats Normal file

Binary file not shown.

5
tests/js/dummy.test.js Normal file
View File

@ -0,0 +1,5 @@
import { expect, test, vi} from 'vitest'
test('dummy test', async () => {
expect(true).toBe(true)
})

12
tox.ini
View File

@ -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

16
vitest.config.js Normal file
View File

@ -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'
}
})