From 2f7c67c953b66969e333a2325268218834d9cae1 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 23 Mar 2019 18:51:32 -0400 Subject: [PATCH] Adding a jest transform to handle yaml files --- jest/yaml.js | 7 +++++++ package.json | 2 ++ yarn.lock | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 jest/yaml.js diff --git a/jest/yaml.js b/jest/yaml.js new file mode 100644 index 0000000..20eb7e3 --- /dev/null +++ b/jest/yaml.js @@ -0,0 +1,7 @@ +const yaml = require('js-yaml'); + +module.exports = { + process(src) { + return `module.exports = ${ JSON.stringify(yaml.safeLoad(src)) };`; + } +}; diff --git a/package.json b/package.json index 059986a..0debeeb 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ ".cache" ], "transform": { + "\\.yaml$": "/jest/yaml.js", "\\.js$": "/jest/preprocess.js", "\\.svg$": "/jest/static-file-transform.js" }, @@ -104,6 +105,7 @@ "i18next-xhr-backend": "^2.0.1", "identity-obj-proxy": "^3.0.0", "jest": "^24.5.0", + "js-yaml": "^3.13.0", "postcss-cssnext": "^3.1.0", "postcss-import": "^12.0.1", "prop-types": "^15.6.2", diff --git a/yarn.lock b/yarn.lock index 44d399b..86d0ca5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7572,7 +7572,7 @@ js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= -js-yaml@^3.10.0, js-yaml@^3.12.0, js-yaml@^3.5.2, js-yaml@^3.9.0: +js-yaml@^3.10.0, js-yaml@^3.12.0, js-yaml@^3.13.0, js-yaml@^3.5.2, js-yaml@^3.9.0: version "3.13.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==