Registry / testing / jest-raw-loader

jest-raw-loader

JSON →
library1.0.1jsnpmunverified

Jest transformer that imports files as raw strings, mimicking webpack-contrib/raw-loader for testing. Current stable version 1.0.1 (last release Jul 22, 2018; long-term maintenance unclear). It reads file content and returns it as a module exporting the string. Simple configuration via Jest's transform option. Unlike other loaders, it directly replaces file imports with their raw content, useful for testing components that import .graphql, .md, or .txt files. No updates since 2018, so may not support newer Jest versions.

npm install jest-raw-loader
INSTALL
IMPORT
SIG · JEST-RAW-LOADER
J
jest-raw-loader
testingjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jest-raw-loader
// package used as Jest transformer in config, not directly imported
const rawLoader = require('jest-raw-loader')
This is a Jest transformer, not a module to import. Configure via jest.transform in package.json or jest.config.js.
jest.transform
"jest": { "transform": { "\\.graphql$": "jest-raw-loader" } }
"jest": { "transform": { "\\.graphql$": "jest-raw-loader/index.js" } }
Specify the module name directly, not path to index.js.
Raw file import
import content from './example.graphql'; // content is a string
const content = require('./example.graphql'); // works but CJS
After configuring, imports of matched files return the raw string. Use ESM or CJS as needed.

Configure Jest to import .graphql and .md files as raw strings, then verify in a test.

// package.json { "jest": { "transform": { "\\.graphql$": "jest-raw-loader", "\\.md$": "jest-raw-loader" } }, "devDependencies": { "jest-raw-loader": "^1.0.1" } } // example.test.js import graphqlContent from './schema.graphql'; test('returns raw string', () => { expect(typeof graphqlContent).toBe('string'); expect(graphqlContent).toContain('type Query'); });
Debug
Known issues
breakingjest-raw-loader may not work with Jest 27+ due to changes in transformer API (sync vs async).
fix
Use a more maintained transformer like jest-transform-raw, or configure Jest custom transformer manually.
affects: <=1.0.1
deprecatedPackage has not been updated since 2018; consider it in maintenance mode.
fix
Evaluate alternatives if you need active maintenance or newer Jest support.
affects: >=0.0.0
gotchaTransform configuration uses regex patterns, not globs. Backslashes in JSON must be double-escaped.
fix
Use "\\.graphql$" (escaped backslash and dot) instead of ".graphql".
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'jest-raw-loader'
Package not installed or not in devDependencies.
fix
Run 'npm install --save-dev jest-raw-loader'
TypeError: Transformer is not a function
Jest version incompatible (Jest 27+ expects async transformer).
fix
Upgrade to a compatible transformer or downgrade Jest to <=26.
Invalid regular expression: /\\.graphql/: \ at end of pattern
Mis-escaped regex in JSON configuration.
fix
Use double backslashes: "\\.graphql$"
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
jest-raw-loader — npm install jest-raw-loader · libregistry