Vitest「describe. sequential is not a function」の原因と直し方
describe.sequential is not a function は、Vitest 5 で無くなった describe.sequential を呼ぶと出る。
第 2 引数に { concurrent: false } を渡せば直る。
公開:
npx vitest run … ⎯⎯⎯⎯⎯⎯ Failed Suites 2 ⎯⎯⎯⎯⎯⎯⎯ FAIL counter.test.js [ counter.test.js ] TypeError: describe.sequential is not a function
npx vitest run … Test Files 2 passed (2) Tests 4 passed (4) Start at 21:50:09 Duration 109ms (tests 54%, transform 25%, import 14%, worker 6%)
2026-11-07 に node:24(Vitest 5.1.0 / Node.js 24.22.2) で実際に打って取った出力。検証環境の詳細
要約
TypeError: describe.sequential is not a function は、Vitest 5 で describe.sequential を呼んだテストファイルが、読み込みの段階で落ちるエラーだ。test.sequential は TypeError: test.sequential is not a function、it.sequential は TypeError: it.sequential is not a function になる。
5.0 は、非推奨だった describe.sequential・test.sequential と、テストのオプションの sequential を取り除いた(公式の移行ガイド(新しいタブで開く))。
テストを並行に走らせる設定の中で一部だけを順番に走らせたいときは、{ concurrent: false } を渡す。
実行例
node:24 のコンテナで Vitest 5.1.0 を入れ、describe.sequential と test.sequential を書いた 2 つのファイルを打つと、どちらも TypeError で落ちた。{ sequential: true } に書き換えると並行に走って値が食い違い、{ concurrent: false } に直すと 4 本とも通った。
$ cat vitest.config.js
import { defineConfig } from "vitest/config";
export default defineConfig({
test: { sequence: { concurrent: true } },
});$ cat counter.test.js
import { describe, expect, test } from "vitest";
let count = 0;
describe.sequential("counter", () => {
test("increment", async () => {
await new Promise((resolve) => setTimeout(resolve, 20));
count += 1;
});
test("read", () => {
expect(count).toBe(1);
});
});$ npx vitest run
RUN v5.1.0 /tmp/tmp.vzuQCc7z4u
❯ queue.test.js (0 test)
❯ counter.test.js (0 test)
⎯⎯⎯⎯⎯⎯ Failed Suites 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL counter.test.js [ counter.test.js ]
TypeError: describe.sequential is not a function
❯ counter.test.js:5:10
3| let count = 0;
4|
5| describe.sequential("counter", () => {
| ^
6| test("increment", async () => {
7| await new Promise((resolve) => setTimeout(resolve, 20));
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL queue.test.js [ queue.test.js ]
TypeError: test.sequential is not a function
❯ queue.test.js:5:6
3| const log = [];
4|
5| test.sequential("first", async () => {
| ^
6| await new Promise((resolve) => setTimeout(resolve, 20));
7| log.push("first");
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 2 failed (2)
Tests no tests
Start at 21:50:08
Duration 109ms (worker 97%, environment 3%)
$ echo $?
1$ cat counter.test.js
import { describe, expect, test } from "vitest";
let count = 0;
describe("counter", { sequential: true }, () => {
test("increment", async () => {
await new Promise((resolve) => setTimeout(resolve, 20));
count += 1;
});
test("read", () => {
expect(count).toBe(1);
});
});$ npx vitest run
RUN v5.1.0 /tmp/tmp.vzuQCc7z4u
❯ counter.test.js (2 tests | 1 failed) 21ms
❯ counter (2)
✓ increment 20ms
× read 4ms
❯ queue.test.js (2 tests | 1 failed) 21ms
✓ first 21ms
× second 4ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL counter.test.js > counter > read
AssertionError: expected +0 to be 1 // Object.is equality
- Expected
+ Received
- 1
+ 0
❯ counter.test.js:12:19
10|
11| test("read", () => {
12| expect(count).toBe(1);
| ^
13| });
14| });
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL queue.test.js > second
AssertionError: expected [ 'second' ] to deeply equal [ 'first', 'second' ]
- Expected
+ Received
[
- "first",
"second",
]
❯ queue.test.js:12:15
10| test("second", { sequential: true }, () => {
11| log.push("second");
12| expect(log).toEqual(["first", "second"]);
| ^
13| });
14|
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 2 failed (2)
Tests 2 failed | 2 passed (4)
Start at 21:50:09
Duration 115ms (tests 54%, transform 22%, import 17%, worker 6%)
$ echo $?
1$ cat counter.test.js
import { describe, expect, test } from "vitest";
let count = 0;
describe("counter", { concurrent: false }, () => {
test("increment", async () => {
await new Promise((resolve) => setTimeout(resolve, 20));
count += 1;
});
test("read", () => {
expect(count).toBe(1);
});
});$ cat queue.test.js
import { expect, test } from "vitest";
const log = [];
test("first", { concurrent: false }, async () => {
await new Promise((resolve) => setTimeout(resolve, 20));
log.push("first");
});
test("second", { concurrent: false }, () => {
log.push("second");
expect(log).toEqual(["first", "second"]);
});$ npx vitest run
RUN v5.1.0 /tmp/tmp.vzuQCc7z4u
✓ queue.test.js (2 tests) 22ms
✓ counter.test.js (2 tests) 22ms
Test Files 2 passed (2)
Tests 4 passed (4)
Start at 21:50:09
Duration 109ms (tests 54%, transform 25%, import 14%, worker 6%)
$ echo $?
0— 2026-11-07 時点の出力
検証環境Node.js 24.22.2 / npm 11.19.1 / Python 3.11.2 / 2026-11-07 検証(ほか 2 件)
- 検証日
- 実行環境
node:24Debian GNU/Linux 12 (bookworm)- バージョン
- Node.js 24.22.2
- npm 11.19.1
- Python 3.11.2
- Git 2.39.5
- Vitest 5.1.0
この記事の「実行例」は、上記の環境で実際にコマンドを実行して得られた出力をそのまま掲載しています。 再現手順はリポジトリの検証スクリプトとして管理し、定期的に再実行して出力を更新しています。
解決策
1. { concurrent: false } を渡す
describe("counter", { concurrent: false }, () => {
test("increment", async () => {
// …
});
});
test("first", { concurrent: false }, async () => {
// …
});describe.sequential("…", fn) は describe("…", { concurrent: false }, fn) に、test.sequential("…", fn) は test("…", { concurrent: false }, fn) に書き換える。it.sequential も同じだ。
オプションのオブジェクトに sequential: true と書いた箇所も、concurrent: false に直す。
describe に渡すと、その中のテストは書いた順に 1 本ずつ走る。
2. 並行に走らせる必要が無ければ設定を外す
sequence.concurrent の既定は false で、1 つのファイルの中のテストは書いた順に走る(sequence の設定(新しいタブで開く))。
並行に走らせたいテストが一部だけなら、設定の concurrent: true を外し、そのテストに test.concurrent を付けるほうが書き換える箇所は少ない。
よくある原因
sequence.concurrent: trueでテストを並行に走らせ、順番が要る describe やテストに.sequentialを付けていた。
5 ではその関数が無いので、ファイルの中のテストは 1 本も走らない。.sequentialをオプションの{ sequential: true }に書き換えた。
こちらはエラーにならないが、5 は値を無視するので、テストは並行に走る。
前のテストが書き換えた値を読むテストが、expected +0 to be 1のような値の食い違いで落ちる。