js: add js unit tests support (#82651)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
82e9018865
commit
7314fa224c
|
@ -14,3 +14,4 @@ junit-py*.xml
|
||||||
.sass-cache/
|
.sass-cache/
|
||||||
passerelle/static/css/style.css
|
passerelle/static/css/style.css
|
||||||
passerelle/static/css/style.css.map
|
passerelle/static/css/style.css.map
|
||||||
|
node_modules/
|
||||||
|
|
|
@ -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 -g vitest happy-dom
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { expect, test} from 'vitest'
|
||||||
|
|
||||||
|
test('test qrcode', async () => {
|
||||||
|
expect(true).toBe(true)
|
||||||
|
})
|
||||||
|
|
12
tox.ini
12
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:RAND_TEST:}
|
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:RAND_TEST:}
|
||||||
envlist = py3-django32-codestyle-coverage,pylint
|
envlist = py3-django32-codestyle-coverage,pylint,vitest
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
|
@ -86,3 +86,13 @@ allowlist_externals =
|
||||||
./pylint.sh
|
./pylint.sh
|
||||||
commands =
|
commands =
|
||||||
./pylint.sh passerelle/ tests/
|
./pylint.sh passerelle/ 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
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
include: ['tests/js/**/*.test.js'],
|
||||||
|
watchExclude: ['**'],
|
||||||
|
alias: {
|
||||||
|
qrcode: fileURLToPath(new URL('./passerelle/apps/qrcode/static/qrcode/js', import.meta.url)),
|
||||||
|
vitest: process.env.NODE_PATH + '/vitest'
|
||||||
|
},
|
||||||
|
environment: 'happy-dom'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue