diff --git a/tests/data/jasmine/README.md b/tests/data/jasmine/README.md new file mode 100644 index 000000000..a7e67a966 --- /dev/null +++ b/tests/data/jasmine/README.md @@ -0,0 +1,41 @@ +Jasmine Runner Usage +===================== + +If you want to test this runner from scratch, start by creating a new jasmine project: + +``` +% npm install --save-dev jasmine jasmine-json-test-reporter +% npx jasmine init +% npx jasmine example +% git add . && git commit -m "Initial commit" +``` + +Create spec/helpers/jasmine-json-test-reporter.js +``` +var JSONReporter = require('jasmine-json-test-reporter'); +jasmine.getEnv().addReporter(new JSONReporter({ + file: 'jasmine-report.json' +})); +``` + +Record tests +``` +BUILD_NAME=jasmine_build +launchable record build --name ${BUILD_NAME} +launchable record session --build ${BUILD_NAME} > session.txt + +# Write all tests to a file +find spec/jasmine_examples -type f > test_list.txt + +# Run all tests +npx jasmine $(cat test_list.txt) + +launchable record tests --base $(pwd) jasmine jasmine-report.json +``` + +Request subset +``` +cat test_list.txt | launchable subset --target 25% jasmine > subset.txt +npx jasmine $(cat subset.txt) +``` + diff --git a/tests/data/jasmine/jasmine-test-results-v3.99.0.json b/tests/data/jasmine/jasmine-test-results-v3.99.0.json new file mode 100644 index 000000000..af251ead3 --- /dev/null +++ b/tests/data/jasmine/jasmine-test-results-v3.99.0.json @@ -0,0 +1,150 @@ +{ + "suite2": { + "id": "suite2", + "description": "when song has been paused", + "fullName": "Player when song has been paused", + "failedExpectations": [], + "deprecationWarnings": [], + "duration": 2, + "properties": null, + "status": "passed", + "specs": [ + { + "id": "spec0", + "description": "should be able to play a Song", + "fullName": "Player should be able to play a Song", + "failedExpectations": [], + "passedExpectations": [ + { + "matcherName": "toEqual", + "message": "Passed.", + "stack": "", + "passed": true + }, + { + "matcherName": "toBePlaying", + "message": "Passed.", + "stack": "", + "passed": true + } + ], + "deprecationWarnings": [], + "pendingReason": "", + "duration": 0, + "properties": null, + "status": "passed" + }, + { + "id": "spec2", + "description": "should be possible to resume", + "fullName": "Player when song has been paused should be possible to resume", + "failedExpectations": [], + "passedExpectations": [ + { + "matcherName": "toBeTruthy", + "message": "Passed.", + "stack": "", + "passed": true + }, + { + "matcherName": "toEqual", + "message": "Passed.", + "stack": "", + "passed": true + } + ], + "deprecationWarnings": [], + "pendingReason": "", + "duration": 1, + "properties": null, + "status": "passed" + }, + { + "id": "spec1", + "description": "should indicate that the song is currently paused", + "fullName": "Player when song has been paused should indicate that the song is currently paused", + "failedExpectations": [], + "passedExpectations": [ + { + "matcherName": "toBeFalsy", + "message": "Passed.", + "stack": "", + "passed": true + }, + { + "matcherName": "toBePlaying", + "message": "Passed.", + "stack": "", + "passed": true + } + ], + "deprecationWarnings": [], + "pendingReason": "", + "duration": 1, + "properties": null, + "status": "passed" + } + ] + }, + "suite3": { + "id": "suite3", + "description": "#resume", + "fullName": "Player #resume", + "failedExpectations": [], + "deprecationWarnings": [], + "duration": 1, + "properties": null, + "status": "passed", + "specs": [ + { + "id": "spec3", + "description": "tells the current song if the user has made it a favorite", + "fullName": "Player tells the current song if the user has made it a favorite", + "failedExpectations": [], + "passedExpectations": [ + { + "matcherName": "toHaveBeenCalledWith", + "message": "Passed.", + "stack": "", + "passed": true + } + ], + "deprecationWarnings": [], + "pendingReason": "", + "duration": 1, + "properties": null, + "status": "passed" + }, + { + "id": "spec4", + "description": "should throw an exception if song is already playing", + "fullName": "Player #resume should throw an exception if song is already playing", + "failedExpectations": [], + "passedExpectations": [ + { + "matcherName": "toThrowError", + "message": "Passed.", + "stack": "", + "passed": true + } + ], + "deprecationWarnings": [], + "pendingReason": "", + "duration": 0, + "properties": null, + "status": "passed" + } + ] + }, + "suite1": { + "id": "suite1", + "description": "Player", + "fullName": "Player", + "failedExpectations": [], + "deprecationWarnings": [], + "duration": 4, + "properties": null, + "status": "passed", + "specs": [] + } +} diff --git a/tests/test_runners/test_jasmine.py b/tests/test_runners/test_jasmine.py index 2a49d07ad..689119292 100644 --- a/tests/test_runners/test_jasmine.py +++ b/tests/test_runners/test_jasmine.py @@ -11,13 +11,26 @@ class JasmineTest(CliTestCase): @responses.activate @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token}) - def test_record_test_json(self): + def test_record_tests_json(self): result = self.cli('record', 'tests', '--session', self.session, 'jasmine', str(self.test_files_dir.joinpath("jasmine-test-results.json"))) self.assert_success(result) self.assert_record_tests_payload('record_test_result.json') + @responses.activate + @mock.patch.dict(os.environ, + {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token}) + def test_record_tests_without_filename(self): + result = self.cli('record', 'tests', '--session', self.session, + 'jasmine', str(self.test_files_dir.joinpath("jasmine-test-results-v3.99.0.json"))) + + self.assertIn( + "does not appear to be valid format. " + "Make sure you are using Jasmine >= v4.6.0 and jasmine-json-test-reporter as the reporter.", + result.output + ) + @responses.activate @mock.patch.dict(os.environ, {"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})