admin管理员组

文章数量:1405157

I have a html table with the following data:


id | name

2 | C

1 | B

3 | A

I need to test the order of table items. I can get the rows using:

wrapper.findAll('table tr')

But how can I assert the order of rows paring the columns (tds) ? Thanks.

I have a html table with the following data:


id | name

2 | C

1 | B

3 | A

I need to test the order of table items. I can get the rows using:

wrapper.findAll('table tr')

But how can I assert the order of rows paring the columns (tds) ? Thanks.

Share Improve this question edited Oct 29, 2019 at 16:41 skyboyer 23.8k7 gold badges62 silver badges71 bronze badges asked Oct 29, 2019 at 13:52 AjjjHshAjjjHsh 2532 gold badges6 silver badges13 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

You can do something like this:

let $rows = wrapper.findAll('tbody > tr').wrappers

let column1 = $rows.map(row => {
  return row.
    findAll('td')
    .at(0)
    .text()
})

expect(column1[0]).toBe('text 1')
expect(column1[1]).toBe('text 2')

本文标签: javascriptjest test table rows and columnsStack Overflow