Skip to content

Commit

Permalink
chore: release script
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 2, 2022
1 parent 2dbc31b commit 4673589
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 67 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Expand Up @@ -20,7 +20,6 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm

# - run: pnpm i -g @antfu/ni
# - run: nci
Expand Down
77 changes: 11 additions & 66 deletions 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)
})

0 comments on commit 4673589

Please sign in to comment.