This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,37 @@ describe('/products', function() {
45
45
});
46
46
});
47
47
```
48
+
49
+ ## building test data
50
+
51
+ Use TestDataBuilder to build many Model instances in one async call. Specify
52
+ only properties relevant to your test, the builder will pre-fill remaining
53
+ required properties with sensible defaults.
54
+
55
+ ``` js
56
+ var TestDataBuilder = require (' loopback-testing' ).TestDataBuilder ;
57
+ var ref = TestDataBuilder .ref ;
58
+
59
+ // The context object to hold the created models.
60
+ // You can use `this` in mocha test instead.
61
+ var context = {};
62
+
63
+ var ref = TestDataBuilder .ref ;
64
+ new TestDataBuilder ()
65
+ .define (' application' , Application, {
66
+ pushSettings: { stub: { } }
67
+ })
68
+ .define (' device' , Device, {
69
+ // use the value of application's id
70
+ // the value is resolved at build time
71
+ appId: ref (' application.id' ),
72
+ deviceType: ' android'
73
+ })
74
+ .define (' notification' , Notification )
75
+ .buildTo (context, function (err ) {
76
+ // test models are available as
77
+ // context.application
78
+ // context.device
79
+ // context.notification
80
+ });
81
+ ```
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " loopback-testing" ,
3
- "version" : " 0.0.3 " ,
3
+ "version" : " 0.0.4 " ,
4
4
"description" : " Utilities for testing LoopBack applications" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
13
13
"supertest" : " ~0.8.2" ,
14
14
"mocha" : " ~1.15.1" ,
15
15
"loopback-datasource-juggler" : " ~1.2.7" ,
16
- "loopback" : " ~1.3.3" ,
17
16
"async" : " ~0.2.9"
18
17
},
18
+ "peerDependencies" : {
19
+ "loopback" : " ~1.3.3"
20
+ },
19
21
"devDependencies" : {
20
- "chai" : " ~1.8.1"
22
+ "chai" : " ~1.8.1" ,
23
+ "loopback" : " ~1.3.3"
21
24
}
22
25
}
You can’t perform that action at this time.
0 commit comments