Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 84 additions & 2 deletions crates/oxc_linter/src/rules/jest/max_expects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl MaxExpects {
fn test() {
use crate::tester::Tester;

let pass = vec![
let mut pass = vec![
("test('should pass')", None),
("test('should pass', () => {})", None),
("test.skip('should pass', () => {})", None),
Expand Down Expand Up @@ -358,7 +358,7 @@ fn test() {
),
];

let fail = vec![
let mut fail = vec![
(
"
test('should not pass', function () {
Expand Down Expand Up @@ -471,6 +471,88 @@ fn test() {
),
];

let pass_vitest = vec![
("test('should pass')", None),
("test('should pass', () => {})", None),
("test.skip('should pass', () => {})", None),
(
"test('should pass', () => {
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
});",
None,
),
(
"test('should pass', () => {
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
});",
None,
),
(
" test('should pass', async () => {
expect.hasAssertions();

expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toEqual(expect.any(Boolean));
});",
None,
),
];

let fail_vitest = vec![
(
"test('should not pass', function () {
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
});
",
None,
),
(
"test('should not pass', () => {
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
});
test('should not pass', () => {
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
expect(true).toBeDefined();
});",
None,
),
(
"test('should not pass', () => {
expect(true).toBeDefined();
expect(true).toBeDefined();
});",
Some(serde_json::json!([{ "max": 1 }])),
),
];

pass.extend(pass_vitest);
fail.extend(fail_vitest);

Tester::new(MaxExpects::NAME, MaxExpects::PLUGIN, pass, fail)
.with_jest_plugin(true)
.test_and_snapshot();
Expand Down
89 changes: 87 additions & 2 deletions crates/oxc_linter/src/rules/jest/max_nested_describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl MaxNestedDescribe {
fn test() {
use crate::tester::Tester;

let pass = vec![
let mut pass = vec![
(
"
describe('foo', function() {
Expand Down Expand Up @@ -287,7 +287,7 @@ fn test() {
),
];

let fail = vec![
let mut fail = vec![
(
"
describe('foo', function() {
Expand Down Expand Up @@ -397,6 +397,91 @@ fn test() {
),
];

let pass_vitest = vec![
(
"
describe('another suite', () => {
describe('another suite', () => {
it('skipped test', () => {
// Test skipped, as tests are running in Only mode
assert.equal(Math.sqrt(4), 3)
})

it.only('test', () => {
// Only this test (and others marked with only) are run
assert.equal(Math.sqrt(4), 2)
})
})
})
",
None,
),
(
"
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {

})
})
})
})
",
None,
),
];

let fail_vitest = vec![
(
"
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {

})
})
})
})
})
})
",
None,
),
(
"
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
describe('another suite', () => {
it('skipped test', () => {
// Test skipped, as tests are running in Only mode
assert.equal(Math.sqrt(4), 3)
})

it.only('test', () => {
// Only this test (and others marked with only) are run
assert.equal(Math.sqrt(4), 2)
})
})
})
})
})
})
})
",
None,
),
];

pass.extend(pass_vitest);
fail.extend(fail_vitest);

Tester::new(MaxNestedDescribe::NAME, MaxNestedDescribe::PLUGIN, pass, fail)
.with_jest_plugin(true)
.test_and_snapshot();
Expand Down
Loading
Loading