{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/359","labels_url":"https://api.github.com/repos/facebook/jest/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/359/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/359/events","html_url":"https://github.com/facebook/jest/pull/359","id":74414750,"number":359,"title":"Make currently-executing test's file path available as jest.currentTestPath()","user":{"login":"drd","id":3490,"avatar_url":"https://avatars.githubusercontent.com/u/3490?v=3","gravatar_id":"","url":"https://api.github.com/users/drd","html_url":"https://github.com/drd","followers_url":"https://api.github.com/users/drd/followers","following_url":"https://api.github.com/users/drd/following{/other_user}","gists_url":"https://api.github.com/users/drd/gists{/gist_id}","starred_url":"https://api.github.com/users/drd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drd/subscriptions","organizations_url":"https://api.github.com/users/drd/orgs","repos_url":"https://api.github.com/users/drd/repos","events_url":"https://api.github.com/users/drd/events{/privacy}","received_events_url":"https://api.github.com/users/drd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/jest/labels/CLA%20Signed","name":"CLA Signed","color":"009900"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-08T16:16:53Z","updated_at":"2015-05-20T23:09:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/jest/pulls/359","html_url":"https://github.com/facebook/jest/pull/359","diff_url":"https://github.com/facebook/jest/pull/359.diff","patch_url":"https://github.com/facebook/jest/pull/359.patch"},"body":"It is useful to have the current test filename available in the test reporter environment. For instance, we use the JUnitReporter with our CI server, and because each test file is run in its own process, this enables us to output a results file named for each test:\r\n\r\n```javascript\r\n// This script enables JUnit XML output by the test runner to be parsed and reported by Bamboo\r\njasmine.VERBOSE = true;\r\n\r\nrequire('jasmine-reporters');\r\n\r\n// massage the test file path into an output filename\r\nvar relativeTestPath = 'test' + _jestTestFilePath\r\n    .replace(process.cwd(), '')\r\n    .replace(/\\//g, '.')\r\n    .replace('__tests__.', '')\r\n    .replace(/\\.jsx?$/, '');\r\n\r\nvar reporter = new jasmine.JUnitXmlReporter('test_results', true, true, relativeTestPath, true);\r\njasmine.getEnv().addReporter(reporter);\r\n```\r\n\r\nI looked a bit into how to best test this but it seemed … complicated :) I would appreciate any thoughts on a nice way to do this? One possibility would be to add it to the `testEnvData` but I feel like that would be a misuse. Otherwise it seems like the way would be to run an end-to-end test with a `setupTestFrameworkScriptFile` configuration parameter, and assert the test filename therein. I'd be happy to add one if that seems like the right approach."},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/104068087","html_url":"https://github.com/facebook/jest/pull/359#issuecomment-104068087","issue_url":"https://api.github.com/repos/facebook/jest/issues/359","id":104068087,"user":{"login":"amasad","id":587518,"avatar_url":"https://avatars.githubusercontent.com/u/587518?v=3","gravatar_id":"","url":"https://api.github.com/users/amasad","html_url":"https://github.com/amasad","followers_url":"https://api.github.com/users/amasad/followers","following_url":"https://api.github.com/users/amasad/following{/other_user}","gists_url":"https://api.github.com/users/amasad/gists{/gist_id}","starred_url":"https://api.github.com/users/amasad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amasad/subscriptions","organizations_url":"https://api.github.com/users/amasad/orgs","repos_url":"https://api.github.com/users/amasad/repos","events_url":"https://api.github.com/users/amasad/events{/privacy}","received_events_url":"https://api.github.com/users/amasad/received_events","type":"User","site_admin":false},"created_at":"2015-05-20T23:09:16Z","updated_at":"2015-05-20T23:09:16Z","body":"Thanks!"}}