Skip to content

Commit 6d64f0e

Browse files
authored
Merge pull request #1191 from cloudbees-oss/LCHIB-653
Add README and a new test for Jasmine runner
2 parents 0e2e283 + 2f7f23d commit 6d64f0e

File tree

3 files changed

+205
-1
lines changed

3 files changed

+205
-1
lines changed

tests/data/jasmine/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Jasmine Runner Usage
2+
=====================
3+
4+
If you want to test this runner from scratch, start by creating a new jasmine project:
5+
6+
```
7+
% npm install --save-dev jasmine jasmine-json-test-reporter
8+
% npx jasmine init
9+
% npx jasmine example
10+
% git add . && git commit -m "Initial commit"
11+
```
12+
13+
Create spec/helpers/jasmine-json-test-reporter.js
14+
```
15+
var JSONReporter = require('jasmine-json-test-reporter');
16+
jasmine.getEnv().addReporter(new JSONReporter({
17+
file: 'jasmine-report.json'
18+
}));
19+
```
20+
21+
Record tests
22+
```
23+
BUILD_NAME=jasmine_build
24+
launchable record build --name ${BUILD_NAME}
25+
launchable record session --build ${BUILD_NAME} > session.txt
26+
27+
# Write all tests to a file
28+
find spec/jasmine_examples -type f > test_list.txt
29+
30+
# Run all tests
31+
npx jasmine $(cat test_list.txt)
32+
33+
launchable record tests --base $(pwd) jasmine jasmine-report.json
34+
```
35+
36+
Request subset
37+
```
38+
cat test_list.txt | launchable subset --target 25% jasmine > subset.txt
39+
npx jasmine $(cat subset.txt)
40+
```
41+
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"suite2": {
3+
"id": "suite2",
4+
"description": "when song has been paused",
5+
"fullName": "Player when song has been paused",
6+
"failedExpectations": [],
7+
"deprecationWarnings": [],
8+
"duration": 2,
9+
"properties": null,
10+
"status": "passed",
11+
"specs": [
12+
{
13+
"id": "spec0",
14+
"description": "should be able to play a Song",
15+
"fullName": "Player should be able to play a Song",
16+
"failedExpectations": [],
17+
"passedExpectations": [
18+
{
19+
"matcherName": "toEqual",
20+
"message": "Passed.",
21+
"stack": "",
22+
"passed": true
23+
},
24+
{
25+
"matcherName": "toBePlaying",
26+
"message": "Passed.",
27+
"stack": "",
28+
"passed": true
29+
}
30+
],
31+
"deprecationWarnings": [],
32+
"pendingReason": "",
33+
"duration": 0,
34+
"properties": null,
35+
"status": "passed"
36+
},
37+
{
38+
"id": "spec2",
39+
"description": "should be possible to resume",
40+
"fullName": "Player when song has been paused should be possible to resume",
41+
"failedExpectations": [],
42+
"passedExpectations": [
43+
{
44+
"matcherName": "toBeTruthy",
45+
"message": "Passed.",
46+
"stack": "",
47+
"passed": true
48+
},
49+
{
50+
"matcherName": "toEqual",
51+
"message": "Passed.",
52+
"stack": "",
53+
"passed": true
54+
}
55+
],
56+
"deprecationWarnings": [],
57+
"pendingReason": "",
58+
"duration": 1,
59+
"properties": null,
60+
"status": "passed"
61+
},
62+
{
63+
"id": "spec1",
64+
"description": "should indicate that the song is currently paused",
65+
"fullName": "Player when song has been paused should indicate that the song is currently paused",
66+
"failedExpectations": [],
67+
"passedExpectations": [
68+
{
69+
"matcherName": "toBeFalsy",
70+
"message": "Passed.",
71+
"stack": "",
72+
"passed": true
73+
},
74+
{
75+
"matcherName": "toBePlaying",
76+
"message": "Passed.",
77+
"stack": "",
78+
"passed": true
79+
}
80+
],
81+
"deprecationWarnings": [],
82+
"pendingReason": "",
83+
"duration": 1,
84+
"properties": null,
85+
"status": "passed"
86+
}
87+
]
88+
},
89+
"suite3": {
90+
"id": "suite3",
91+
"description": "#resume",
92+
"fullName": "Player #resume",
93+
"failedExpectations": [],
94+
"deprecationWarnings": [],
95+
"duration": 1,
96+
"properties": null,
97+
"status": "passed",
98+
"specs": [
99+
{
100+
"id": "spec3",
101+
"description": "tells the current song if the user has made it a favorite",
102+
"fullName": "Player tells the current song if the user has made it a favorite",
103+
"failedExpectations": [],
104+
"passedExpectations": [
105+
{
106+
"matcherName": "toHaveBeenCalledWith",
107+
"message": "Passed.",
108+
"stack": "",
109+
"passed": true
110+
}
111+
],
112+
"deprecationWarnings": [],
113+
"pendingReason": "",
114+
"duration": 1,
115+
"properties": null,
116+
"status": "passed"
117+
},
118+
{
119+
"id": "spec4",
120+
"description": "should throw an exception if song is already playing",
121+
"fullName": "Player #resume should throw an exception if song is already playing",
122+
"failedExpectations": [],
123+
"passedExpectations": [
124+
{
125+
"matcherName": "toThrowError",
126+
"message": "Passed.",
127+
"stack": "",
128+
"passed": true
129+
}
130+
],
131+
"deprecationWarnings": [],
132+
"pendingReason": "",
133+
"duration": 0,
134+
"properties": null,
135+
"status": "passed"
136+
}
137+
]
138+
},
139+
"suite1": {
140+
"id": "suite1",
141+
"description": "Player",
142+
"fullName": "Player",
143+
"failedExpectations": [],
144+
"deprecationWarnings": [],
145+
"duration": 4,
146+
"properties": null,
147+
"status": "passed",
148+
"specs": []
149+
}
150+
}

tests/test_runners/test_jasmine.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,26 @@ class JasmineTest(CliTestCase):
1111
@responses.activate
1212
@mock.patch.dict(os.environ,
1313
{"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
14-
def test_record_test_json(self):
14+
def test_record_tests_json(self):
1515
result = self.cli('record', 'tests', '--session', self.session,
1616
'jasmine', str(self.test_files_dir.joinpath("jasmine-test-results.json")))
1717

1818
self.assert_success(result)
1919
self.assert_record_tests_payload('record_test_result.json')
2020

21+
@responses.activate
22+
@mock.patch.dict(os.environ,
23+
{"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})
24+
def test_record_tests_without_filename(self):
25+
result = self.cli('record', 'tests', '--session', self.session,
26+
'jasmine', str(self.test_files_dir.joinpath("jasmine-test-results-v3.99.0.json")))
27+
28+
self.assertIn(
29+
"does not appear to be valid format. "
30+
"Make sure you are using Jasmine >= v4.6.0 and jasmine-json-test-reporter as the reporter.",
31+
result.output
32+
)
33+
2134
@responses.activate
2235
@mock.patch.dict(os.environ,
2336
{"LAUNCHABLE_TOKEN": CliTestCase.launchable_token})

0 commit comments

Comments
 (0)