You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importTestRunnerfrom'test-runner'importassertfrom'assert'importfetchfrom'node-fetch'consttom=newTestRunner.Tom()tom.test('Math.random() should return a number between 0 and 1',function(){constresult=Math.random()assert.equal(typeofresult,'number')assert.ok(result>=0&&result<=1)})tom.test('REST API should return the current todo item',asyncfunction(){constresponse=awaitfetch('https://jsonplaceholder.typicode.com/todos/1')consttodo=awaitresponse.json()assert.equal(todo.userId,1)assert.equal(todo.title,'delectus aut autem')})exportdefaulttom
Run the tests using esm-runner. This runner is identical to test-runner with the one difference that it supports ECMAScript Modules (ESM).
$ npx esm-runner test.mjs
Start: 2 tests loaded
✓ synopsis Math.random() should return a number between 0 and 1
✓ synopsis REST API should return the current todo item
Completed in 199ms. Pass: 2, fail: 0, skip: 0.