Skip to content

Commit a2098d8

Browse files
authored
chore(e2e): surface errors better in e2e test helper (#4195)
1 parent 7caa548 commit a2098d8

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

features/ec2/step_definitions/ec2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Given("I attempt to copy an encrypted snapshot across regions", function (callba
4444
const dstEc2 = new EC2({ region: destRegion });
4545

4646
function teardown() {
47-
if (volId) srcEc2.deleteVolume({ VolumeId: volId }).send();
48-
if (srcSnapId) srcEc2.deleteSnapshot({ SnapshotId: srcSnapId }).send();
49-
if (dstSnapId) dstEc2.deleteSnapshot({ SnapshotId: dstSnapId }).send();
47+
if (volId) srcEc2.deleteVolume({ VolumeId: volId });
48+
if (srcSnapId) srcEc2.deleteSnapshot({ SnapshotId: srcSnapId });
49+
if (dstSnapId) dstEc2.deleteSnapshot({ SnapshotId: dstSnapId });
5050
}
5151

5252
params = {

features/extra/helpers.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ module.exports = {
7777
world.data = data;
7878

7979
try {
80-
if (typeof next.condition === "function") {
80+
if (next && typeof next.condition === "function") {
8181
const condition = next.condition.call(world, world);
8282
if (!condition) {
83-
next.fail(new Error("Request success condition failed"));
83+
next.fail(new Error("Request success condition failed."));
8484
return;
8585
}
8686
}
@@ -91,10 +91,16 @@ module.exports = {
9191
} else if (extra !== false && err) {
9292
world.unexpectedError(svc.config.signingName, operation, world.error.name, world.error.message, next);
9393
} else {
94-
next.call(world);
94+
if (typeof next.call === "function") {
95+
next.call(world);
96+
}
9597
}
9698
} catch (err) {
97-
next.fail(err);
99+
if (next && typeof next.fail === "function") {
100+
next.fail(err);
101+
return;
102+
}
103+
throw err;
98104
}
99105
});
100106
},
@@ -105,7 +111,12 @@ module.exports = {
105111
* operation failed.
106112
*/
107113
unexpectedError: function unexpectedError(svc, op, name, msg, next) {
108-
next.fail(new Error(`Received unexpected error from ${svc}.${op}, ${name}: ${msg}`));
114+
var err = new Error(`Received unexpected error from ${svc}.${op}, ${name}: ${msg}`);
115+
if (next && typeof next.fail === "function") {
116+
next.fail(err);
117+
return;
118+
}
119+
throw err;
109120
},
110121

111122
/**

features/s3/step_definitions/buckets.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ Before({ tags: "@buckets" }, function () {
77

88
After({ tags: "@buckets" }, function (callback) {
99
if (this.bucket) {
10-
this.request("s3", "deleteBucket", { Bucket: this.bucket }, callback);
11-
this.bucket = undefined;
10+
this.s3
11+
.deleteBucket({ Bucket: this.bucket })
12+
.catch(() => {})
13+
.then(() => {
14+
this.bucket = undefined;
15+
})
16+
.then(callback);
1217
} else {
1318
callback();
1419
}
@@ -33,7 +38,7 @@ Given(
3338
);
3439

3540
When("I create a bucket with the location constraint {string}", function (location, callback) {
36-
const bucket = (this.bucket = this.uniqueName("aws-sdk-js-integration"));
41+
this.bucket = this.uniqueName("aws-sdk-js-integration");
3742
const params = {
3843
Bucket: this.bucket,
3944
CreateBucketConfiguration: {

0 commit comments

Comments
 (0)