util.request({ url: 'http://resspeed.test.whistlejs.com/', body: util.getTextBySize(128 * 2 + 1), method: 'post' }, function(res, data) { now = Date.now() - now; now.should.above(2000); });
describe('#__del', () => { it('should be the same as new NodeCache().del', () => { filesystem(); const cache = new Cache(); const nCache = new NodeCache(); cache.__set('yyz', 'amazing'); const returnone = cache.__del('yyz'); nCache.set('yyz', 'amazing'); const returntwo = nCache.del('yyz'); returnone.should.eql(returntwo); filesystem.restore(); }); });
it("GET " + apiPrefix + "offices/ugroupby?_fields= should PASS", function( done ) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=") //enter url .expect(400) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } Object.keys(res.body).length.should.be.equals(1); return done(); }); });
util.request('http://resdelay.test.whistlejs.com/', function(res, data) { now = Date.now() - now; now.should.above(1000); });
it('should not retry session', async () => { retryFailedStep({ retries: 1, minTimeout: 1 }); event.dispatcher.emit(event.test.before, {}); event.dispatcher.emit(event.step.started, { name: 'click' }); let counter = 0; try { session('foo', () => { recorder.add(() => { counter++; throw new Error(); }); }); await recorder.promise(); } catch (e) { recorder.catchWithoutStop((err) => {}); } // expects to retry only once counter.should.equal(2); });
it( "GET " + apiPrefix + "offices?_fields=officeCode,city should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=officeCode,city") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); Object.keys(res.body[0]).length.should.be.equal(2); return done(); }); } );
it('should add custom steps to ignore', async () => { retryFailedStep({ retries: 2, minTimeout: 1, ignoredSteps: ['somethingNew*'] }); event.dispatcher.emit(event.test.before, {}); let counter = 0; event.dispatcher.emit(event.step.started, { name: 'somethingNew' }); try { recorder.add(() => { counter++; if (counter < 3) { throw new Error(); } }); await recorder.promise(); } catch (e) { recorder.catchWithoutStop((err) => { }); } counter.should.equal(1); // expects to retry only once });
it( "GET " + apiPrefix + "offices/ugroupby?_fields=country,city should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=country,city") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body).length.should.be.equals(2); res.body["country"].length.should.be.equals(5); res.body["city"].length.should.be.equals(7); return done(); }); } );
it( "GET " + apiPrefix + "offices/ugroupby?_fields=country should PASS", function(done) { //post to an url with data agent .get(apiPrefix + "offices/ugroupby?_fields=country") //enter url .expect(200) //200 for success 4xx for failure .end(function(err, res) { // Handle /api/v error if (err) { return done(err); } //validate response Object.keys(res.body).length.should.be.equals(1); res.body["country"].length.should.be.equals(5); return done(); }); } );
it('should not retry within', async () => { retryFailedStep({ retries: 1, minTimeout: 1 }); event.dispatcher.emit(event.test.before, {}); let counter = 0; event.dispatcher.emit(event.step.started, { name: 'click' }); try { within('foo', () => { recorder.add(() => { counter++; throw new Error(); }); }); await recorder.promise(); } catch (e) { recorder.catchWithoutStop((err) => {}); } // expects to retry only once counter.should.equal(2); });
util.request({ url: 'http://reqspeed.test.whistlejs.com/', method: 'post', body: util.getTextBySize(128 * 2 + 1) }, function(res, data) { now = Date.now() - now; now.should.above(2000); });
util.request('http://reqdelay.test.whistlejs.com/', function(res, data) { now = Date.now() - now; now.should.above(1000); });
it('should not retry steps with wait*', async () => { retryFailedStep({ retries: 2, minTimeout: 1 }); event.dispatcher.emit(event.test.before, {}); let counter = 0; event.dispatcher.emit(event.step.started, { name: 'waitForElement' }); try { recorder.add(() => { counter++; if (counter < 3) { throw new Error(); } }); await recorder.promise(); } catch (e) { recorder.catchWithoutStop((err) => { }); } counter.should.equal(1); // expects to retry only once });
it('should not retry steps with amOnPage', async () => { retryFailedStep({ retries: 2, minTimeout: 1 }); event.dispatcher.emit(event.test.before, {}); let counter = 0; event.dispatcher.emit(event.step.started, { name: 'amOnPage' }); try { recorder.add(() => { counter++; if (counter < 3) { throw new Error(); } }); await recorder.promise(); } catch (e) { recorder.catchWithoutStop((err) => { }); } counter.should.equal(1); // expects to retry only once });
it( "GET " + apiPrefix + "offices?_fields=officeCode,ity should PASS", function(done) { //http get an url agent .get(apiPrefix + "offices?_fields=officeCode,ity") // api url .expect(200) // 2xx for success and 4xx for failure .end(function(err, res) { // Handle /api/offices/1/employees error if (err) { return done(err); } //validate resonse res.body.should.be.instanceOf(Array); // ity in _fields is an in valid column and it should be ignored Object.keys(res.body[0]).length.should.be.equal(1); return done(); }); } );