Skip to content

class with uvu

狼叔 edited this page Feb 23, 2021 · 3 revisions

test case

// tests/demo.js
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
const test = suite('test')

class MyFirstJUnitJupiterTests {
  abc: number = 1

  a() {
    console.dir(this)
    assert.is(Math.sqrt(4), 2)
  }

}

const obj = new MyFirstJUnitJupiterTests()

test('aa', obj.a.bind(obj))

test.run();

执行结果

$ ts tests/uvu.ts
 test  MyFirstJUnitJupiterTests { abc: 1 }
   (1 / 1)

  Total:     1
  Passed:    1
  Skipped:   0
  Duration:  2.43ms

more

// tests/demo.js
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
const test = suite('test')

class MyFirstJUnitJupiterTests {
  abc: number = 1

  a() {
    console.dir(this)
    assert.is(Math.sqrt(4), 2)
  }

}

const obj = new MyFirstJUnitJupiterTests()

test('aa', obj.a.bind(obj))
test('bb', obj.a.bind(obj))

test.before.each(function(){
  console.log('each')
})

test.run();
Clone this wiki locally