mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-17 13:20:52 +08:00
test: add umd test
This commit is contained in:
parent
15a75e2db0
commit
b557833f04
@ -71,7 +71,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
{
|
||||
files: '*.spec.ts',
|
||||
files: ['*.spec.ts', '*.spec.js'],
|
||||
globals: {
|
||||
describe: 'readonly',
|
||||
it: 'readonly',
|
||||
|
@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"start": "pnpm run dev",
|
||||
"dev": "pnpm run clean && pnpm run gen-version && pnpm run gen-volar-dts && cross-env NODE_ENV=development vite",
|
||||
"build:package": "pnpm run gen-version && pnpm run clean && pnpm run gen-volar-dts && tsc -b --force tsconfig.esm.json && node scripts/pre-build/pre-cjs-build.js && tsc -b --force tsconfig.cjs.json && rollup -c && node scripts/post-build && rimraf {es,lib}/*.tsbuildinfo",
|
||||
"build:package": "pnpm run gen-version && pnpm run clean && pnpm run gen-volar-dts && tsc -b --force tsconfig.esm.json && node scripts/pre-build/pre-cjs-build.js && tsc -b --force tsconfig.cjs.json && rollup -c && pnpm run test:umd && node scripts/post-build && rimraf {es,lib}/*.tsbuildinfo",
|
||||
"build:site": "./scripts/pre-build-site/pre-build-site.sh && cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 vite build && ./scripts/post-build-site/post-build-site.sh",
|
||||
"clean": "rimraf site lib es dist node_modules/naive-ui themes/**/es themes/**/lib",
|
||||
"release:package": "pnpm run test && pnpm run build:package && pnpm publish --no-git-checks",
|
||||
@ -28,6 +28,7 @@
|
||||
"test:update": "cross-env NODE_ENV=test jest -u --collectCoverage=false",
|
||||
"test:cov": "cross-env NODE_ENV=test NODE_OPTIONS=--unhandled-rejections=warn jest",
|
||||
"test:watch": "cross-env NODE_ENV=test jest ---watch --verbose --coverage",
|
||||
"test:umd": "jest --collectCoverage=false --testMatch=\"<rootDir>/umd-test/index.spec.js\"",
|
||||
"gen-version": "node scripts/gen-version",
|
||||
"gen-volar-dts": "esbuild scripts/gen-component-declaration.js --bundle --platform=node --tsconfig=tsconfig.esbuild.json | node",
|
||||
"build:site:ts": "./scripts/pre-build-site/pre-build-site.sh && cross-env TUSIMPLE=true NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 vite build && ./scripts/post-build-site/post-build-site.sh",
|
||||
|
20
umd-test/index.spec.js
Normal file
20
umd-test/index.spec.js
Normal file
@ -0,0 +1,20 @@
|
||||
import './setupVue.js'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
// eslint-disable-next-line n/no-exports-assign
|
||||
exports = undefined
|
||||
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(
|
||||
fs.readFileSync(path.resolve(__dirname, '..', 'dist', 'index.js')).toString()
|
||||
)
|
||||
|
||||
describe('umd', () => {
|
||||
it('works', () => {
|
||||
const div = document.createElement('div')
|
||||
document.body.appendChild(div)
|
||||
window.Vue.createApp(window.naive.NDataTable).mount(div)
|
||||
expect(div.innerHTML).toContain('n-data-table')
|
||||
})
|
||||
})
|
3
umd-test/setupVue.js
Normal file
3
umd-test/setupVue.js
Normal file
@ -0,0 +1,3 @@
|
||||
import * as Vue from 'vue'
|
||||
|
||||
window.Vue = Vue
|
Loading…
Reference in New Issue
Block a user