Skip to content

Broken conversion from tape tests #123

Open
@chrvadala

Description

@chrvadala

Hi guys,
I think that the conversion from tape doesn't work, because the tape t.plan(N) function and expect.assertions(N) have different behaviours; Moreover, Jest has this different way to work with callbacks https://jestjs.io/docs/en/asynchronous.html#callbacks

TAPE TEST

var test = require('tape');

test('', t => {
	t.plan(2)

	setTimeout(() => {
		t.ok(true)		
	}, 4000)

        setTimeout(() => {
		t.ok(true)
	}, 3000)
})

TAPE LOG

TAP version 13
# (anonymous)
ok 1 should be truthy
ok 2 should be truthy
1..2
# tests 2
# pass  2
# ok

JEST TEST (CONVERTED)

test('', () => {
	expect.assertions(2)
	
	setTimeout(() => {
		expect(true).toBeTruthy()		
	}, 4000)

	setTimeout(() => {
		expect(true).toBeTruthy()
	}, 3000)
})

JEST LOG

Expected two assertions to be called but received zero assertion calls.

      1 | test('', () => {
    > 2 | 	expect.assertions(2)
        | 	       ^
      3 | 	
      4 | 	setTimeout(() => {
      5 | 		expect(true).toBeTruthy()		

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions