Skip to content

Commit 358a335

Browse files
flovilmartdplewis
authored andcommitted
Moves integration test at top level with jasmine (#593)
* Moves integration test at top level with jasmine - Use jasmine so toolchain is similar to parse-server - Replaces bash script with pre-test * Update contributing guide * Updates URLs * nits * nits * nit
1 parent 25d13ed commit 358a335

30 files changed

+2545
-3089
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ integration/test_logs
99
.DS_Store
1010
.idea/
1111
integration/test_logs
12+
test_logs
1213
out/
1314
docs/

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ jobs:
2222
before_script:
2323
- npm install -g mongodb-runner
2424
- mongodb-runner start
25-
script: npm test -- --maxWorkers=4 && ./run_integration.sh
25+
script:
26+
- npm test -- --maxWorkers=4
27+
- npm run integration
2628
after_script: ./node_modules/codecov/bin/codecov -f ./coverage/coverage-final.json && rm -rf ./coverage
2729
# release on github latest branch
2830
- stage: release
29-
env:
31+
env:
32+
-
3033
before_script: skip
3134
after_script: skip
3235
script:

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"jasmineExplorer.config": "jasmine.json",
3+
"jasmineExplorer.env": {
4+
"TESTING": "1"
5+
}
6+
}

CONTRIBUTING.md

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,97 @@
11
# Contributing to the Parse JavaScript SDK
22
We want to make contributing to this project as easy and transparent as possible.
33

4-
If you're looking to get started, but want to ease yourself into the codebase, look for issues tagged [good first bug](https://github.com/ParsePlatform/Parse-SDK-JS/labels/good%20first%20bug). These are simple yet valuable tasks that should be easy to get started.
4+
If you're looking to get started, but want to ease yourself into the codebase, look for issues tagged [good first task](https://github.com/parse-community/Parse-SDK-JS/labels/good%20first%20task). These are simple yet valuable tasks that should be easy to get started.
55

6-
## Code of Conduct
7-
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
6+
## `master` is unsafe
7+
Our goal is to keep `master` stable, but there may be changes that your application may not be compatible with. We'll do our best to publicize any breaking changes, but try to use our specific releases in any production environment.
88

9-
## Our Development Process
10-
Most of our work will be done in public directly on GitHub. There may be changes done through our internal source control, but it will be rare and only as needed.
9+
## Setting up the project for debugging and contributing:
1110

12-
### `master` is unsafe
13-
Our goal is to keep `master` stable, but there may be changes that your application may not be compatible with. We'll do our best to publicize any breaking changes, but try to use our specific releases in any production environment.
11+
### Recommended setup:
12+
13+
* [vscode](https://code.visualstudio.com), the popular IDE.
14+
* [Jest Extension](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest) the Jest extension for vscode to run the tests inline and debug quicky.
15+
* [Jasmine Test Explorer Extension](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-test-explorer), a very practical test exploration plugin which let you run, debug and see the test results inline.
16+
* [mongodb-runner](https://github.com/mongodb-js/runner) Easily install and run MongoDB to test your code against it. (install with `npm install -g mongodb-runner`)
17+
18+
### Setting up you local machine:
19+
20+
* [Fork](https://github.com/parse-community/Parse-SDK-JS) this project and clone the fork on your local machine:
21+
22+
```sh
23+
$ git clone https://github.com/parse-community/Parse-SDK-JS
24+
$ cd Parse-SDK-JS # go into the clone directory
25+
$ npm install # install all the node dependencies
26+
$ code . # launch vscode
27+
```
28+
29+
### Testing the code
30+
31+
The SDK is tested through two lenses. unit tests are run with jest and integrationt tests with jasmine.
32+
33+
Two different frameworks are used as the integration tests leverage a stateful server, with the data saved into the database, and Jest is running many tests in parallel, which makes it incompatible with our integration tests.
34+
35+
#### Unit tests
36+
37+
Those tests are located in [/src/__tests__](/src/__tests__) and are responsible for ensuring each class is behaving as expected, without considering the rest of the system. For example, adding a new query helper function would probably require to add relevant tests that ensure the query is properly serialized to a valid Parse REST query object. Unit tests heavily leverage mocking and are an essential part of our testing harness.
38+
39+
To run unit tests, run `npm test`. If you have the vscode Jest plugin extension (as recommended), you can run your tests by clicking the *Debug* lens that appears near by the test.
40+
41+
42+
#### Integration tests
43+
44+
Those tests are located in [/integration/test](/integration/test) and are responsible for ensuring a proper communication with parse-server. With the integration tests, we ensure all communications between the SDK and the server are behaving accordingly.
45+
46+
To run the integtation tests, you will need a valid mongodb running on your local machine. You can get easily mongodb running with `mongodb-runner` (see [Recommended setup](#recommended-setup)).
47+
48+
Use `npm run integration` in order to run the integration tests. If you have the vscode Jasmine extension installed (as recommended), you can run your tests by clicking the *Run* or the *Debug* lens that appears near by the test.
1449

1550
### Pull Requests
1651
We actively welcome your pull requests. When we get one, we'll run some Parse-specific integration tests on it first. From here, we'll need to get a core member to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
1752

1853
1. Fork the repo and create your branch from `master`.
1954
2. Add unit tests for any new code you add.
2055
3. If you've changed APIs, update the documentation.
21-
4. Ensure the test suite passes.
56+
4. Ensure the test suite passes. (run `npm test && npm run integration`)
2257
5. Make sure your code lints.
23-
6. If you haven't already, complete the Contributor License Agreement ("CLA").
24-
25-
### Contributor License Agreement ("CLA")
26-
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects.
27-
28-
Complete your CLA here: <https://developers.facebook.com/opensource/cla>
29-
30-
31-
## Bugs
32-
Although we try to keep developing on Parse easy, you still may run into some issues. General questions should be asked on [Google Groups][google-group], technical questions should be asked on [Stack Overflow][stack-overflow], and for everything else we'll be using GitHub issues.
3358

3459
### Known Issues
3560
We use GitHub issues to track public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new issue, try to make sure your problem doesn't already exist.
3661

3762
### Reporting New Issues
3863
Not all issues are SDK issues. If you're unsure whether your bug is with the SDK or backend, you can test to see if it reproduces with our [REST API][rest-api] and [Parse API Console][parse-api-console]. If it does, you can report backend bugs [here][bug-reports].
64+
If the issue only reproduces with the JS SDK, you can [open an issue](https://github.com/parse-community/parse-server/issues) on this repository.
3965

4066
Details are key. The more information you provide us the easier it'll be for us to debug and the faster you'll receive a fix. Some examples of useful tidbits:
4167

4268
* A description. What did you expect to happen and what actually happened? Why do you think that was wrong?
43-
* A simple unit test that fails. Refer [here][tests-dir] for examples of existing unit tests. See our [README](README.md#usage) for how to run unit tests. You can submit a pull request with your failing unit test so that our CI verifies that the test fails.
69+
* A simple unit test that fails. Refer [here][tests-dir] for examples of existing unit tests and [here][integration-test-dir] for integration tests examples. See for how to setup your machine and run unit tests in [this](#setting-up-the-project-for-debugging-and-contributing) guide. You can submit a pull request with your failing unit test so that our CI verifies that the test fails.
4470
* What version does this reproduce on? What version did it last work on?
4571
* [Stacktrace or GTFO][stacktrace-or-gtfo]. In all honesty, full stacktraces with line numbers make a happy developer.
4672
* Anything else you find relevant.
4773

4874
### Security Bugs
49-
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
75+
Parse Community has a [responsible Vulnerability Disclosure Program](https://github.com/parse-community/parse-server/blob/master/SECURITY.md) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
5076

5177
## Coding Style
5278
* Most importantly, match the existing code style as much as possible.
5379
* We use [Flow](http://flowtype.org/) and ES6 for this codebase. Use modern syntax whenever possible.
5480
* Keep lines within 80 characters.
5581
* Always end lines with semicolons.
5682

83+
### Code of Conduct
84+
85+
This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/parse-community/parse-server/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to honor this code.
86+
5787
## License
5888
By contributing to the Parse JavaScript SDK, you agree that your contributions will be licensed under its license.
5989

6090
[google-group]: https://groups.google.com/forum/#!forum/parse-developers
61-
[stack-overflow]: http://stackoverflow.com/tags/parse.com
62-
[bug-reports]: https://www.parse.com/help#report
63-
[rest-api]: https://www.parse.com/docs/rest/guide
64-
[parse-api-console]: http://blog.parse.com/announcements/introducing-the-parse-api-console/
91+
[stack-overflow]: http://stackoverflow.com/tags/parse-server
92+
[bug-reports]: https://github.com/parse-community/parse-server/issues
93+
[rest-api]: https://docs.parseplatform.org/rest/guide
94+
[parse-api-console]: http://blog.parseplatform.org/announcements/introducing-the-parse-api-console/
6595
[stacktrace-or-gtfo]: http://i.imgur.com/jacoj.jpg
6696
[tests-dir]: /src/__tests__
97+
[integration-test-dir]: /integration/test

0 commit comments

Comments
 (0)