Non-code files #

You can import JSON, text, or binary data. This is useful for bootstrapping tests with reference data, dictionaries, configuration, etc. Use ES import attributes to specify the type of import:

import data from "./fixtures/data.json" with { type: "json" };
import contents from "./wordlist.txt" with { type: "text" };
import raw from "./snapshot.dat" with { type: "binary" };

When using "text" you get a string, and when using "binary" you get Uint8Array.

For JSON data, you can also just use the file extension:

import data from "./fixtures/data.json";