mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
test: add basic benchmark tests (#24846)
This commit is contained in:
parent
2cab4cba12
commit
ba0d274b9d
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: CI
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -102,6 +102,35 @@ jobs:
|
||||
with:
|
||||
category: "/language:javascript"
|
||||
|
||||
benchmark:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: {}
|
||||
needs:
|
||||
- build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
- run: corepack enable
|
||||
- uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
|
||||
with:
|
||||
node-version: 20
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Restore dist cache
|
||||
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
|
||||
with:
|
||||
name: dist
|
||||
path: packages
|
||||
|
||||
- name: Run benchmarks
|
||||
uses: CodSpeedHQ/action@ad0378e48c3cb4c700f1cdc5e10943dbad3cc4ec # v2.0.2
|
||||
with:
|
||||
run: pnpm vitest bench
|
||||
token: ${{ secrets.CODSPEED_TOKEN }}
|
||||
|
||||
typecheck:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 10
|
||||
|
@ -42,6 +42,7 @@
|
||||
"magic-string": "^0.30.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codspeed/vitest-plugin": "^2.3.1",
|
||||
"@nuxt/eslint-config": "0.2.0",
|
||||
"@nuxt/test-utils": "3.9.0",
|
||||
"@nuxt/webpack-builder": "workspace:*",
|
||||
|
23
packages/kit/test/load-nuxt-config.bench.ts
Normal file
23
packages/kit/test/load-nuxt-config.bench.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { bench, describe } from 'vitest'
|
||||
import { join, normalize } from 'pathe'
|
||||
import { withoutTrailingSlash } from 'ufo'
|
||||
import { loadNuxtConfig } from '../src'
|
||||
|
||||
const fixtures = {
|
||||
'empty directory': 'node_modules/fixture',
|
||||
'basic test fixture': 'test/fixtures/basic',
|
||||
'basic test fixture (types)': 'test/fixtures/basic-types',
|
||||
'minimal test fixture': 'test/fixtures/minimal',
|
||||
'minimal test fixture (types)': 'test/fixtures/minimal-types',
|
||||
}
|
||||
|
||||
describe('loadNuxtConfig', () => {
|
||||
for (const fixture in fixtures) {
|
||||
const relativeDir = join('../../..', fixtures[fixture as keyof typeof fixtures])
|
||||
const path = withoutTrailingSlash(normalize(fileURLToPath(new URL(relativeDir, import.meta.url))))
|
||||
bench(fixture, async () => {
|
||||
await loadNuxtConfig({ cwd: path })
|
||||
})
|
||||
}
|
||||
})
|
19
packages/kit/test/write-types.bench.ts
Normal file
19
packages/kit/test/write-types.bench.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { afterAll, bench, describe } from 'vitest'
|
||||
import { join, normalize } from 'pathe'
|
||||
import { withoutTrailingSlash } from 'ufo'
|
||||
import { loadNuxt, writeTypes } from '../src'
|
||||
|
||||
describe('writeTypes', async () => {
|
||||
const relativeDir = join('../../..', 'test/fixtures/basic-types')
|
||||
const path = withoutTrailingSlash(normalize(fileURLToPath(new URL(relativeDir, import.meta.url))))
|
||||
|
||||
const nuxt = await loadNuxt({ cwd: path })
|
||||
afterAll(async () => {
|
||||
await nuxt.close()
|
||||
})
|
||||
|
||||
bench('write types', async () => {
|
||||
await writeTypes(nuxt)
|
||||
})
|
||||
})
|
26
packages/nuxt/test/load-nuxt.bench.ts
Normal file
26
packages/nuxt/test/load-nuxt.bench.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { bench, describe } from 'vitest'
|
||||
import { normalize } from 'pathe'
|
||||
import { withoutTrailingSlash } from 'ufo'
|
||||
import { loadNuxt } from '../src'
|
||||
|
||||
const emptyDir = withoutTrailingSlash(normalize(fileURLToPath(new URL('../../../node_modules/fixture', import.meta.url))))
|
||||
const basicTestFixtureDir = withoutTrailingSlash(normalize(fileURLToPath(new URL('../../../test/fixtures/basic', import.meta.url))))
|
||||
|
||||
describe('loadNuxt', () => {
|
||||
bench('empty directory', async () => {
|
||||
const nuxt = await loadNuxt({
|
||||
cwd: emptyDir,
|
||||
ready: true
|
||||
})
|
||||
await nuxt.close()
|
||||
})
|
||||
|
||||
bench('basic test fixture', async () => {
|
||||
const nuxt = await loadNuxt({
|
||||
cwd: basicTestFixtureDir,
|
||||
ready: true
|
||||
})
|
||||
await nuxt.close()
|
||||
})
|
||||
})
|
@ -19,6 +19,9 @@ importers:
|
||||
|
||||
.:
|
||||
devDependencies:
|
||||
'@codspeed/vitest-plugin':
|
||||
specifier: ^2.3.1
|
||||
version: 2.3.1(vite@5.0.10)(vitest@1.1.0)
|
||||
'@nuxt/eslint-config':
|
||||
specifier: 0.2.0
|
||||
version: 0.2.0(eslint@8.56.0)
|
||||
@ -1206,6 +1209,24 @@ packages:
|
||||
dependencies:
|
||||
mime: 3.0.0
|
||||
|
||||
/@codspeed/core@2.3.1:
|
||||
resolution: {integrity: sha512-7KRwBX4iXK33gEQwh8jPWBF9srGIjewm3oc+A/66caiG/aOyHmxJCapjAZxT2f2vIVYqR7CghzqlxY2ik0DNBg==}
|
||||
dependencies:
|
||||
find-up: 6.3.0
|
||||
node-gyp-build: 4.6.1
|
||||
dev: true
|
||||
|
||||
/@codspeed/vitest-plugin@2.3.1(vite@5.0.10)(vitest@1.1.0):
|
||||
resolution: {integrity: sha512-/e4G2B/onX/hG/EjUU/NpDxnIryeTDamVRTBeWfgQDoex3g7GDzTwoQktaU5l/Asw3ZjEErQg+oQVToQ6jYZlA==}
|
||||
peerDependencies:
|
||||
vite: 5.0.10
|
||||
vitest: '>=1.0.0-beta.4 || >=1'
|
||||
dependencies:
|
||||
'@codspeed/core': 2.3.1
|
||||
vite: 5.0.10(@types/node@20.10.5)
|
||||
vitest: 1.1.0(@types/node@20.10.5)(happy-dom@12.10.3)
|
||||
dev: true
|
||||
|
||||
/@discoveryjs/json-ext@0.5.7:
|
||||
resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
@ -5138,6 +5159,14 @@ packages:
|
||||
locate-path: 6.0.0
|
||||
path-exists: 4.0.0
|
||||
|
||||
/find-up@6.3.0:
|
||||
resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
locate-path: 7.2.0
|
||||
path-exists: 5.0.0
|
||||
dev: true
|
||||
|
||||
/flat-cache@3.1.1:
|
||||
resolution: {integrity: sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
@ -6312,6 +6341,13 @@ packages:
|
||||
dependencies:
|
||||
p-locate: 5.0.0
|
||||
|
||||
/locate-path@7.2.0:
|
||||
resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
p-locate: 6.0.0
|
||||
dev: true
|
||||
|
||||
/lodash-es@4.17.21:
|
||||
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||
|
||||
@ -7221,6 +7257,13 @@ packages:
|
||||
dependencies:
|
||||
yocto-queue: 0.1.0
|
||||
|
||||
/p-limit@4.0.0:
|
||||
resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
yocto-queue: 1.0.0
|
||||
dev: true
|
||||
|
||||
/p-limit@5.0.0:
|
||||
resolution: {integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==}
|
||||
engines: {node: '>=18'}
|
||||
@ -7241,6 +7284,13 @@ packages:
|
||||
dependencies:
|
||||
p-limit: 3.1.0
|
||||
|
||||
/p-locate@6.0.0:
|
||||
resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
p-limit: 4.0.0
|
||||
dev: true
|
||||
|
||||
/p-map@4.0.0:
|
||||
resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==}
|
||||
engines: {node: '>=10'}
|
||||
@ -7324,6 +7374,11 @@ packages:
|
||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
/path-exists@5.0.0:
|
||||
resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dev: true
|
||||
|
||||
/path-is-absolute@1.0.1:
|
||||
resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { resolve } from 'node:path'
|
||||
import { configDefaults, defineConfig } from 'vitest/config'
|
||||
import { isWindows } from 'std-env'
|
||||
import codspeedPlugin from '@codspeed/vitest-plugin'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [codspeedPlugin()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'#build/nuxt.config.mjs': resolve('./test/mocks/nuxt-config'),
|
||||
|
Loading…
Reference in New Issue
Block a user