Skip to content

Commit

Permalink
Initialize test fixture from document definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSneerJaw committed Mar 8, 2018
1 parent 2a691a6 commit 4192339
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
An example [couchster](https://github.com/OldSneerJaw/couchster) project that demonstrates the basics of writing specifications/test cases using the built in test-fixture-maker module. Refer to the couchster [README](https://github.com/OldSneerJaw/couchster/blob/master/README.md), [test-fixture-maker](https://github.com/OldSneerJaw/couchster/blob/master/src/testing/test-fixture-maker.js) module and [validation-error-formatter](https://github.com/OldSneerJaw/couchster/blob/master/src/testing/validation-error-formatter.js) module for more information.

Run `npm install` and `npm test` to download project dependencies and then execute the test cases.
Instructions:

- Download project dependencies: `npm install`
- Validate document definitions and run test cases: `npm test`
- Generate the validation functions in the `build` directory: `npm run build`
- Clean up all build artifacts: `npm run clean`
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"mocha": "^5.0.4"
},
"scripts": {
"build": "couchster src/my-example-doc-definitions.js build/my-example-validation-function.js",
"build": "npm run validate && couchster src/my-example-doc-definitions.js build/my-example-validation-function.js",
"clean": "rm -rf build",
"test": "npm run validate && npm run build && mocha",
"test": "npm run validate && mocha",
"validate": "couchster-validate src/my-example-doc-definitions.js"
}
}
2 changes: 1 addition & 1 deletion test/my-example-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('my example document definitions', function() {
// Need to initialize the test fixture module the document definitions under test before every test case
var testFixture;
beforeEach(function() {
testFixture = testFixtureMaker.initFromValidationFunction('build/my-example-validation-function.js');
testFixture = testFixtureMaker.initFromDocumentDefinitions('src/my-example-doc-definitions.js');
});

it('should consider the document valid when all constraints are met', function() {
Expand Down

0 comments on commit 4192339

Please sign in to comment.