vim-test / vim-test

Run your tests at the speed of thought

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JEST - `Test Nearest` on tests that has `.each()` does not work

ckangnz opened this issue · comments

When you have jest tests;

describe.each([1, 2 ])('Loop the test with given array',()=>{})

it.each([1, 2 ])('Loop the test with given array',()=>{})

test.each([1, 2 ])('Loop the test with given array',()=>{})

the functionality of "Test Nearest" does not work and skips the test.

Could you please confirm if this is still an issue after updating to the latest version of the plug-in

I'll check it out next monday when I'm back at work!! Looking forward to experience the bug fix!! Thank you

@codeinabox it seems like they're not working.

I have tests that are:

  1. NOT WORKING
describe.each([1,2])('Given %s' , (number)=>{
  it.each(['a','b'])(' should print %s', (string)=>{
    expect(number).toBe(number); <---------- TEST THIS
    expect(string).toBe(string);
  })
})

  1. NOT WORKING
describe.each([1,2])('Given %s' , (number)=>{
  it(' should print a', ()=>{
    expect(number).toBe(number); <-------- TEST THIS
  })
})
  1. NOT WORKING
describe('Given number is 1' , ()=>{
  it.each(['a','b'])(' should print %s', (string)=>{
    expect(string).toBe(string); <----------TEST THIS
  })
})

Thank you for checking, so to confirm TestNearest is being called on the lines where you have "<----------TEST THIS"?

@codeinabox that's correct.

I just pulled down the latest update on vim-test, and apparently there was a fix around playwright test #682.

When I tested, it looks like it is half working. The test at least doesn't skip anymore, however, only a single test runs.

For example,

describe('Given number is 1' , ()=>{
  it.each(['a','b'])(' should print %s', (string)=>{
    expect(string).toBe(string); <----------TEST THIS
  })
})

will only run for the b case.

Given I have these tests:

describe('Given number is 1', () => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(string).toBe(string);<--- CURSOR HERE
  });
});

describe.each([1, 2])('Given %s', number => {
  it('should print a', () => {
    expect(number).toBe(number); 
  });
});
describe.each([1, 2])('Given %s', number => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(number).toBe(number);
    expect(string).toBe(string);
  });
});

The test SKIPS.


describe('Given number is 1', () => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(string).toBe(string);
  });
});

describe.each([1, 2])('Given %s', number => {
  it('should print a', () => {
    expect(number).toBe(number); <--- CURSOR HERE
  });
});
describe.each([1, 2])('Given %s', number => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(number).toBe(number);
    expect(string).toBe(string);
  });
});

I get
image


describe('Given number is 1', () => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(string).toBe(string);
  });
});

describe.each([1, 2])('Given %s', number => {
  it('should print a', () => {
    expect(number).toBe(number); 
  });
});
describe.each([1, 2])('Given %s', number => {
  it.each(['a', 'b'])('should print %s', string => {
    expect(number).toBe(number);<--- CURSOR HERE
    expect(string).toBe(string);
  });
});

The test SKIPS.

The describe.each() only runs a single test
The it.each() skips completely.

same issue for me, do you guys have any update?

Thank you for all these examples that aren't working properly, we should add them to the spec for Jest so this issue can be resolved. I am pretty flat out these days, though if I find time I'll look into it.

Thanks so much! Wish i could be more helpful to contribute but I'm not too familiar with vim script..😅