{"id":20151,"library":"jest-raw-loader","title":"jest-raw-loader","description":"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.","status":"maintenance","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/keplersj/jest-raw-loader","tags":["javascript"],"install":[{"cmd":"npm install jest-raw-loader","lang":"bash","label":"npm"},{"cmd":"yarn add jest-raw-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-raw-loader","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is a Jest transformer, not a module to import. Configure via jest.transform in package.json or jest.config.js.","wrong":"const rawLoader = require('jest-raw-loader')","symbol":"jest-raw-loader","correct":"// package used as Jest transformer in config, not directly imported"},{"note":"Specify the module name directly, not path to index.js.","wrong":"\"jest\": { \"transform\": { \"\\\\.graphql$\": \"jest-raw-loader/index.js\" } }","symbol":"jest.transform","correct":"\"jest\": { \"transform\": { \"\\\\.graphql$\": \"jest-raw-loader\" } }"},{"note":"After configuring, imports of matched files return the raw string. Use ESM or CJS as needed.","wrong":"const content = require('./example.graphql'); // works but CJS","symbol":"Raw file import","correct":"import content from './example.graphql'; // content is a string"}],"quickstart":{"code":"// package.json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.graphql$\": \"jest-raw-loader\",\n      \"\\\\.md$\": \"jest-raw-loader\"\n    }\n  },\n  \"devDependencies\": {\n    \"jest-raw-loader\": \"^1.0.1\"\n  }\n}\n\n// example.test.js\nimport graphqlContent from './schema.graphql';\n\ntest('returns raw string', () => {\n  expect(typeof graphqlContent).toBe('string');\n  expect(graphqlContent).toContain('type Query');\n});","lang":"javascript","description":"Configure Jest to import .graphql and .md files as raw strings, then verify in a test."},"warnings":[{"fix":"Use a more maintained transformer like jest-transform-raw, or configure Jest custom transformer manually.","message":"jest-raw-loader may not work with Jest 27+ due to changes in transformer API (sync vs async).","severity":"breaking","affected_versions":"<=1.0.1"},{"fix":"Evaluate alternatives if you need active maintenance or newer Jest support.","message":"Package has not been updated since 2018; consider it in maintenance mode.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use \"\\\\.graphql$\" (escaped backslash and dot) instead of \".graphql\".","message":"Transform configuration uses regex patterns, not globs. Backslashes in JSON must be double-escaped.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev jest-raw-loader'","cause":"Package not installed or not in devDependencies.","error":"Cannot find module 'jest-raw-loader'"},{"fix":"Upgrade to a compatible transformer or downgrade Jest to <=26.","cause":"Jest version incompatible (Jest 27+ expects async transformer).","error":"TypeError: Transformer is not a function"},{"fix":"Use double backslashes: \"\\\\.graphql$\"","cause":"Mis-escaped regex in JSON configuration.","error":"Invalid regular expression: /\\\\.graphql/: \\ at end of pattern"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}