# no-incomplete-assertions

Rule `sonarjs/no-incomplete-assertions`. Assertions should be complete

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1288 by reach, #589 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-incomplete-assertions` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-2970/) |

## Code examples

### Incorrect: the rule reports this

```js
const assert = require('chai').assert;
const expect = require('chai').expect;

describe("incomplete assertions", function() {
    const value = 42;

    it("uses chai 'assert'", function() {
        assert.fail;  // Noncompliant
    });

    it("uses chai 'expect'", function() {
        expect(1 == 1);  // Noncompliant
        expect(value.toString).to.throw;  // Noncompliant
    });
});
```

### Correct: the rule accepts this

```js
const assert = require('chai').assert;
const expect = require('chai').expect;

describe("incomplete assertions", function() {
    const value = 42;

    it("uses chai 'assert'", function() {
        assert.fail();
    });

    it("uses chai 'expect'", function() {
        expect(1).to.equal(1);
        expect(value.toString).throw(TypeError);
    });
});
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-incomplete-assertions": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-incompatible-assertion-types](https://lintradar.dev/rules/sonarjs/no-incompatible-assertion-types.md): Assertions comparing incompatible types should not be made
- [sonarjs/no-internal-api-use](https://lintradar.dev/rules/sonarjs/no-internal-api-use.md): Users should not use internal APIs
- [sonarjs/no-in-misuse](https://lintradar.dev/rules/sonarjs/no-in-misuse.md): "in" should not be used on arrays
- [sonarjs/no-interpolation-in-inline-snapshots](https://lintradar.dev/rules/sonarjs/no-interpolation-in-inline-snapshots.md): Inline snapshots should not contain interpolations
- [sonarjs/no-implicit-global](https://lintradar.dev/rules/sonarjs/no-implicit-global.md): Variables should be declared explicitly
- [sonarjs/no-invalid-regexp](https://lintradar.dev/rules/sonarjs/no-invalid-regexp.md): Regular expressions should be syntactically valid

---

Web page: https://lintradar.dev/rules/sonarjs/no-incomplete-assertions. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
