Mocha to Vitest - Migrate Tests

verified codemod icon

Run this codemod to upgrade your codebase from using mocha to vitest.

Vitest
jscodeshift
Estimated time saving
5+ minutes/file
Change mode
Assistive
Applicability criteria

Mocha >= 9.0.0

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod mocha/vitest/migrate-tests
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

Run this codemod to upgrade your codebase from using mocha to vitest.

Example

Before

import { expect } from 'chai';

describe('Test Suite 1', () => {
    it('addition', () => {
    expect(1 + 1).to.equal(2);
    });
});

After

import { describe, it, expect } from 'vitest';

describe('Test Suite 1', () => {
    it('addition', () => {
    expect(1 + 1).to.equal(2);
    });
});