{"action":"created","issue":{"url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/828","repository_url":"https://api.github.com/repos/kulshekhar/ts-jest","labels_url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/828/labels{/name}","comments_url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/828/comments","events_url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/828/events","html_url":"https://github.com/kulshekhar/ts-jest/issues/828","id":373987034,"node_id":"MDU6SXNzdWUzNzM5ODcwMzQ=","number":828,"title":"Array.flat() is not a function","user":{"login":"aaronbeall","id":2973900,"node_id":"MDQ6VXNlcjI5NzM5MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/2973900?v=4","gravatar_id":"","url":"https://api.github.com/users/aaronbeall","html_url":"https://github.com/aaronbeall","followers_url":"https://api.github.com/users/aaronbeall/followers","following_url":"https://api.github.com/users/aaronbeall/following{/other_user}","gists_url":"https://api.github.com/users/aaronbeall/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronbeall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronbeall/subscriptions","organizations_url":"https://api.github.com/users/aaronbeall/orgs","repos_url":"https://api.github.com/users/aaronbeall/repos","events_url":"https://api.github.com/users/aaronbeall/events{/privacy}","received_events_url":"https://api.github.com/users/aaronbeall/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-10-25T14:49:57Z","updated_at":"2018-10-29T16:23:30Z","closed_at":"2018-10-28T04:46:36Z","author_association":"NONE","body":"<!-- First of all, check the troubleshooting wiki page for common issues at:\r\nhttps://github.com/kulshekhar/ts-jest/wiki/Troubleshooting -->\r\n\r\n## Issue <!-- describe the issue below -->:\r\nUsing `ts-jest` preprocessor some of my tests are failing because the code under test uses `Array.prototype.flat()`, which I can properly polyfill using `core-js` or `babel-polyfill` but when run in Jest I just get the runtime error `array.flat() is not a function`\r\n\r\n## Expected behavior <!-- describe the expected behavior below -->:\r\n\r\n`array.flat` works in Jest tests\r\n\r\n## Debug log:\r\n<details/>\r\n<summary>log file content<!-- You can activate the debug logger by setting the environment variable TS_JEST_LOG=\"ts-jest.log\" before running tests. The output of the logger will be in **ts-jest.log** in CWD, paste it in the below section: --></summary>\r\n\r\n```bash\r\n# content of ts-jest.log :\r\n\r\n```\r\n</details>\r\n\r\n\r\n## Minimal repo <!-- If you haven't already, create the smallest possible repo that reproduces this issue by running `npm install` and `npm test`. This will speed up any fixes that this issue might need. Paste the minimal repo URL below -->:\r\n\r\n**package.json:**\r\n```\r\n{\r\n  \"jest\": {\r\n    \"transform\": {\r\n      \".(ts|tsx)\": \"<rootDir>/node_modules/ts-jest/preprocessor.js\"\r\n    },\r\n    \"testRegex\": \"(/__tests__/.*|\\\\.(test|spec))\\\\.(ts|tsx|js)$\",\r\n    \"moduleFileExtensions\": [\r\n      \"ts\",\r\n      \"tsx\",\r\n      \"js\"\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\n**flatten.ts:**\r\n```\r\nexport function flatten(array: any[]): any[] {\r\n  return array.flat();\r\n}\r\n```\r\n\r\n**flatten.spec.ts:**\r\n```\r\nimport { flatten } from \"./flatten\";\r\ntest(\"array.flat\", () => {\r\n  expect(flatten([[[0]]])).toEqual([0]);\r\n});\r\n```\r\n\r\n<!-- Optional (but highly recommended): Configure Travis (or your favorite system) with the minimal repo. This allows potential solutions to be tested against the minimal repo. This saves everyone time and avoids a lot of back and forth. -->\r\n"},"comment":{"url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/comments/433976880","html_url":"https://github.com/kulshekhar/ts-jest/issues/828#issuecomment-433976880","issue_url":"https://api.github.com/repos/kulshekhar/ts-jest/issues/828","id":433976880,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzk3Njg4MA==","user":{"login":"aaronbeall","id":2973900,"node_id":"MDQ6VXNlcjI5NzM5MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/2973900?v=4","gravatar_id":"","url":"https://api.github.com/users/aaronbeall","html_url":"https://github.com/aaronbeall","followers_url":"https://api.github.com/users/aaronbeall/followers","following_url":"https://api.github.com/users/aaronbeall/following{/other_user}","gists_url":"https://api.github.com/users/aaronbeall/gists{/gist_id}","starred_url":"https://api.github.com/users/aaronbeall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaronbeall/subscriptions","organizations_url":"https://api.github.com/users/aaronbeall/orgs","repos_url":"https://api.github.com/users/aaronbeall/repos","events_url":"https://api.github.com/users/aaronbeall/events{/privacy}","received_events_url":"https://api.github.com/users/aaronbeall/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T16:23:30Z","updated_at":"2018-10-29T16:23:30Z","author_association":"NONE","body":"> You should import core-js within [setupFiles](https://jestjs.io/docs/en/configuration.html#setupfiles-array) or [setupTestFrameworkScriptFile](https://jestjs.io/docs/en/configuration.html#setuptestframeworkscriptfile-string)\r\n\r\nExactly what I was looking for! Adding `\"setupFiles\": [\"core-js\"]` to my config fixed my original error. Thanks again for your help!"}}
{"actor":{"display_login":"aaronbeall"}}