From 4673589125572ede3eb374a96fd8431c807e9e58 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 3 May 2022 01:33:26 +0800 Subject: [PATCH] chore: release script --- .github/workflows/release.yml | 1 - test/core/test/basic.test.ts | 77 +++++------------------------------ 2 files changed, 11 insertions(+), 67 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c758cc1c069b..5e7808a66e51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - cache: pnpm # - run: pnpm i -g @antfu/ni # - run: nci diff --git a/test/core/test/basic.test.ts b/test/core/test/basic.test.ts index 4b6a735716c4..f20ec3535075 100644 --- a/test/core/test/basic.test.ts +++ b/test/core/test/basic.test.ts @@ -1,74 +1,19 @@ -import { assert, expect, it, suite, test } from 'vitest' -import { two } from '../src/submodule' -import { timeout } from '../src/timeout' +import { it } from 'vitest' -test('Math.sqrt()', async () => { - assert.equal(Math.sqrt(4), two) - assert.equal(Math.sqrt(2), Math.SQRT2) - expect(Math.sqrt(144)).toStrictEqual(12) - // await new Promise(resolve => setTimeout(resolve, 3000)) -}) - -test('JSON', () => { - const input = { - foo: 'hello', - bar: 'world', - } - - const output = JSON.stringify(input) +const isDev = process.env.NODE_ENV === 'development' - expect(input).toEqual({ - foo: 'hello', - bar: 'world', +if (!isDev) { + it('prod only tests', () => { + /* ... */ }) - expect(output).toEqual('{"foo":"hello","bar":"world"}') - assert.deepEqual(JSON.parse(output), input, 'matches original') -}) +} -test('mode and NODE_ENV is test by default', () => { - expect(process.env.NODE_ENV).toBe('test') - expect(import.meta.env.MODE).toBe('test') +// Now in Vitest v0.10.1 +it.skipIf(isDev)('prod only tests', () => { + /* ... */ }) -test('assertion is callable', () => { - const str = '13' - expect(str).to.be.a('string') - expect(str).not.to.be.a('number') +it.runIf(isDev)('dev only tests', () => { + /* ... */ }) -const hi = suite('suite') - -hi.test('expect truthy', () => { - expect({}).toBeTruthy() - expect(null).not.toBeTruthy() -}) - -// Remove .skip to test async fail by timeout -test.skip('async with timeout', async () => { - return new Promise((resolve) => { - setTimeout(() => { - resolve() - }, 200) - }) -}, 100) - -it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) - -it.fails('deprecated done callback', (done) => { - done() -}) - -const shouldSkip = true - -it.skipIf(shouldSkip)('skipped', () => { - throw new Error('foo') -}) -it.skipIf(!shouldSkip)('not skipped', () => { - expect(1).toBe(1) -}) -it.runIf(!shouldSkip)('skipped 2', () => { - throw new Error('foo') -}) -it.runIf(shouldSkip)('not skipped 2', () => { - expect(1).toBe(1) -})