tests: configure vitest and happy-dom (#75221)
This commit is contained in:
parent
632c18b825
commit
e7d327cd50
File diff suppressed because it is too large
Load Diff
|
@ -30,11 +30,13 @@
|
|||
"devDependencies": {
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-node-resolve": "^13.0.6",
|
||||
"happy-dom": "^12.5.0",
|
||||
"rollup": "^2.26.3",
|
||||
"rollup-plugin-terser": "^6.0.4"
|
||||
"rollup-plugin-terser": "^6.0.4",
|
||||
"vitest": "^0.34.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "true",
|
||||
"test": "vitest --run",
|
||||
"build": "rollup -c",
|
||||
"watch": "rollup -c -w",
|
||||
"prepare": "npm run build"
|
||||
|
|
|
@ -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 clean-install
|
|
@ -0,0 +1,4 @@
|
|||
env:
|
||||
node: true
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import Godo from '../src-js/godo'
|
||||
import {test, expect} from 'vitest'
|
||||
|
||||
test('test create editor', async () => {
|
||||
const form = document.createElement('form')
|
||||
const textArea = document.createElement('textarea')
|
||||
form.appendChild(textArea)
|
||||
const godo = new Godo(textArea, {})
|
||||
expect(godo).not.toBe(undefined)
|
||||
expect(document.querySelector('.godo')).not.toBe(undefined)
|
||||
})
|
||||
|
12
tox.ini
12
tox.ini
|
@ -1,10 +1,13 @@
|
|||
[tox]
|
||||
envlist = pre-commit
|
||||
envlist = pre-commit,test
|
||||
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/godo.js/
|
||||
|
||||
[testenv]
|
||||
whitelist_externals =
|
||||
/bin/mv
|
||||
npm
|
||||
npx
|
||||
bash
|
||||
setenv =
|
||||
PYTHONPATH=.
|
||||
SETUPTOOLS_USE_DISTUTILS=stdlib
|
||||
|
@ -15,3 +18,10 @@ deps =
|
|||
pre-commit
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
[testenv:test]
|
||||
deps = nodeenv
|
||||
install_command = bash setup-vitest.sh {packages}
|
||||
setenv =
|
||||
NODE_PATH={envdir}/lib/node_modules
|
||||
commands = npx vitest --run
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: 'tests/**/*.test.js',
|
||||
watchExclude: ['**'],
|
||||
alias: {
|
||||
godo: fileURLToPath(new URL('./src-js', import.meta.url)),
|
||||
},
|
||||
environment: 'happy-dom',
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue