Skip to content

Commit 5e18d55

Browse files
Record Sentry test responses and default to using fixtures (#74)
1 parent aaa57d2 commit 5e18d55

47 files changed

Lines changed: 711 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
node_modules
44
.tmp/
55
dist/
6+
yarn-error.log

CONTRIBUTING.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,30 @@
22

33
Thanks for being willing to contribute! 👍
44

5-
**Are you working on your first pull request?** [This (free) video series on Egghead](egghead) is a pretty good starting place 🙂
5+
**Are you working on your first pull request?** [This (free) video series on Egghead][egghead] is a pretty good starting place. 🙂
66

77
## Project Set Up
88

99
1. Fork and clone the repo
10-
2. `npm install`
11-
3. Create a Sentry test account and generate an API key [here](sentry-api)
12-
4. `cp .env.example .env` and fill in with your test account credentials
13-
5. `npm validate` to ensure that everything is installed & setup correctly
14-
15-
This project uses [`nps`](https://github.com/kentcdodds/nps). Running `npm start` will list all available commands (in green at the bottom).
10+
2. Install [yarn](https://yarnpkg.com/lang/en/docs/install) if you don't already have it
11+
3. `yarn install`
12+
4. `yarn validate` to ensure that everything is installed & setup correctly
1613

1714
## Tests
1815

19-
Tests can be run with `nam test`. Linting can be run with `npm run lint`
16+
Tests can be run with `yarn test`. Linting can be run with `yarn lint`.
17+
18+
The project uses [replayer][replayer]. Running `yarn test:record` will run the tests against a real Sentry instance, and cache its HTTP responses as fixtures. The default test command (`yarn test`) will run the tests against those fixtures, so you don't need to have a Sentry instance set up just to run the tests.
2019

21-
⚠️ The test suite will create releases & upload files. They should be cleaned up afterward, but ensure that you are not overwriting something important! ⚠️
20+
If you need to add new tests, you will also need to regenerate the fixtures. To do this:
21+
22+
1. Create a Sentry test account and generate an API key [here][sentry-api]
23+
2. `cp .env.example .env` and fill in with your test account credentials
24+
3. Run `yarn test:record`. ⚠️ The test suite will create releases & upload files. They should be cleaned up afterward, but ensure that you are not overwriting something important! ⚠️ Your API key and organization name are automatically filtered and will not be stored in the fixtures; however, the name of your Sentry project will be included in response fixtures, so don't name it anything embarrassing. 🙂
2225

2326
## Formating
2427

25-
Formatting is done with [prettier](prettier). Run `npm start format` to format the code.
28+
Formatting is done with [prettier][prettier]. Run `yarn format` to format the code.
2629

2730
## Opt into git hooks
2831

@@ -34,6 +37,6 @@ pre-push
3437
```
3538

3639
[egghead]: https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github
40+
[replayer]: https://github.com/aneilbaboo/replayer
3741
[sentry-api]: https://sentry.io/api
3842
[prettier]: https://github.com/prettier/prettier
39-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dateReleased": null, "commitCount": 0, "url": null, "data": {}, "lastDeploy": null, "deployCount": 0, "dateCreated": "2019-05-14T13:59:34.778Z", "lastEvent": null, "version": "function-release", "firstEvent": null, "lastCommit": null, "shortVersion": "function-release", "authors": [], "owner": null, "newGroups": 0, "ref": null, "projects": [{"slug": "sentry-demo", "name": "Sentry Demo"}]}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"statusCode": 201,
3+
"headers": {
4+
"server": "nginx",
5+
"date": "Tue, 14 May 2019 13:59:34 GMT",
6+
"content-type": "application/json",
7+
"content-length": "393",
8+
"connection": "keep-alive",
9+
"x-xss-protection": "1; mode=block",
10+
"content-language": "en",
11+
"x-content-type-options": "nosniff",
12+
"vary": "Accept-Language, Cookie",
13+
"allow": "GET, POST, HEAD, OPTIONS",
14+
"x-frame-options": "deny",
15+
"x-served-by": "web-17b74f97",
16+
"strict-transport-security": "max-age=31536000; includeSubDomains; preload"
17+
},
18+
"url": "https://sentry.io:443/api/0/organizations/test-organization/releases/",
19+
"time": 241,
20+
"request": {
21+
"method": "POST",
22+
"headers": {
23+
"Content-Type": "application/json",
24+
"host": "sentry.io",
25+
"authorization": "Bearer test-api-key",
26+
"content-length": 57
27+
}
28+
}
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dateReleased": null, "commitCount": 0, "url": null, "data": {}, "lastDeploy": null, "deployCount": 0, "dateCreated": "2019-05-14T13:59:33.965Z", "lastEvent": null, "version": "string-release", "firstEvent": null, "lastCommit": null, "shortVersion": "string-release", "authors": [], "owner": null, "newGroups": 0, "ref": null, "projects": [{"slug": "sentry-demo", "name": "Sentry Demo"}]}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"statusCode": 201,
3+
"headers": {
4+
"server": "nginx",
5+
"date": "Tue, 14 May 2019 13:59:34 GMT",
6+
"content-type": "application/json",
7+
"content-length": "389",
8+
"connection": "keep-alive",
9+
"x-xss-protection": "1; mode=block",
10+
"content-language": "en",
11+
"x-content-type-options": "nosniff",
12+
"vary": "Accept-Language, Cookie",
13+
"allow": "GET, POST, HEAD, OPTIONS",
14+
"x-frame-options": "deny",
15+
"x-served-by": "web-17b74f97",
16+
"strict-transport-security": "max-age=31536000; includeSubDomains; preload"
17+
},
18+
"url": "http://sentry.io:443/api/0/organizations/test-organization/releases/",
19+
"time": 427,
20+
"request": {
21+
"method": "POST",
22+
"headers": {
23+
"Content-Type": "application/json",
24+
"host": "sentry.io",
25+
"authorization": "Bearer test-api-key",
26+
"content-length": 55
27+
}
28+
}
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sha1": "430b8e9fb0a1c781248cac3ad37b169b927cfee5", "dist": null, "name": "~/index.bundle.js.map", "dateCreated": "2019-05-14T13:59:34.305Z", "headers": {"Content-Type": "application/json"}, "id": "338283692", "size": 2774}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"statusCode": 201,
3+
"headers": {
4+
"server": "nginx",
5+
"date": "Tue, 14 May 2019 13:59:34 GMT",
6+
"content-type": "application/json",
7+
"content-length": "224",
8+
"connection": "keep-alive",
9+
"x-xss-protection": "1; mode=block",
10+
"content-language": "en",
11+
"x-content-type-options": "nosniff",
12+
"vary": "Accept-Language, Cookie",
13+
"allow": "GET, POST, HEAD, OPTIONS",
14+
"x-frame-options": "deny",
15+
"x-served-by": "web-c401c6a4",
16+
"strict-transport-security": "max-age=31536000; includeSubDomains; preload"
17+
},
18+
"url": "https://sentry.io:443/api/0/organizations/test-organization/releases/string-release/files/",
19+
"time": 205,
20+
"request": {
21+
"method": "POST",
22+
"headers": {
23+
"host": "sentry.io",
24+
"authorization": "Bearer test-api-key",
25+
"content-type": "multipart/form-data; boundary=--------------------------730611279482887420628155",
26+
"content-length": 3121
27+
}
28+
}
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"dateReleased": null, "commitCount": 0, "url": null, "data": {}, "lastDeploy": null, "deployCount": 0, "dateCreated": "2019-05-14T13:59:33.965Z", "lastEvent": null, "version": "string-release", "firstEvent": null, "lastCommit": null, "shortVersion": "string-release", "authors": [], "owner": null, "newGroups": 0, "ref": null, "projects": [{"slug": "sentry-demo", "name": "Sentry Demo"}]}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"server": "nginx",
5+
"date": "Tue, 14 May 2019 13:59:34 GMT",
6+
"content-type": "application/json",
7+
"content-length": "389",
8+
"connection": "keep-alive",
9+
"x-xss-protection": "1; mode=block",
10+
"content-language": "en",
11+
"x-content-type-options": "nosniff",
12+
"vary": "Accept-Language, Cookie",
13+
"allow": "GET, PUT, DELETE, HEAD, OPTIONS",
14+
"x-frame-options": "deny",
15+
"x-served-by": "web-c401c6a4",
16+
"strict-transport-security": "max-age=31536000; includeSubDomains; preload"
17+
},
18+
"url": "http://sentry.io:443/api/0/projects/test-organization/test-project/releases/string-release/",
19+
"time": 222,
20+
"request": {
21+
"method": "GET",
22+
"headers": {
23+
"host": "sentry.io",
24+
"authorization": "Bearer test-api-key",
25+
"accept": "application/json"
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)