Skip to content

Commit b128906

Browse files
committed
fix(tests): e2e tests returns exit code 1 when failing
1 parent 59d4997 commit b128906

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

tests/e2e/e2e_workflow.spec.js

+34-33
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ describe('Basic end-to-end Workflow', function () {
6565
'--silent'
6666
]).then(function() {
6767
expect(fs.existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
68+
}).catch((err) => {
69+
throw new Error('Build failed.');
6870
});
6971
});
7072

@@ -87,7 +89,8 @@ describe('Basic end-to-end Workflow', function () {
8789

8890
return ng(testArgs)
8991
.then(function(result) {
90-
expect(result.exitCode).to.be.equal(0);
92+
const exitCode = typeof result === 'object' ? result.exitCode : result;
93+
expect(exitCode).to.be.equal(0);
9194
});
9295
});
9396

@@ -111,7 +114,8 @@ describe('Basic end-to-end Workflow', function () {
111114

112115
return ng(testArgs)
113116
.then(function(result) {
114-
expect(result.exitCode).to.be.equal(0);
117+
const exitCode = typeof result === 'object' ? result.exitCode : result;
118+
expect(exitCode).to.be.equal(0);
115119
});
116120
});
117121

@@ -133,7 +137,8 @@ describe('Basic end-to-end Workflow', function () {
133137

134138
return ng(testArgs)
135139
.then(function(result) {
136-
expect(result.exitCode).to.be.equal(0);
140+
const exitCode = typeof result === 'object' ? result.exitCode : result;
141+
expect(exitCode).to.be.equal(0);
137142
});
138143
});
139144

@@ -155,7 +160,8 @@ describe('Basic end-to-end Workflow', function () {
155160

156161
return ng(testArgs)
157162
.then(function(result) {
158-
expect(result.exitCode).to.be.equal(0);
163+
const exitCode = typeof result === 'object' ? result.exitCode : result;
164+
expect(exitCode).to.be.equal(0);
159165
});
160166
});
161167

@@ -186,41 +192,36 @@ describe('Basic end-to-end Workflow', function () {
186192

187193
return ng(testArgs)
188194
.then(function(result) {
189-
expect(result.exitCode).to.be.equal(0);
190-
191-
// Clean `tmp` folder
192-
// process.chdir(path.resolve(root, '..'));
193-
// sh.rm('-rf', './tmp'); // tmp.teardown takes too long
195+
const exitCode = typeof result === 'object' ? result.exitCode : result;
196+
expect(exitCode).to.be.equal(0);
194197
});
195198
});
196199

197200
it('Turn on `noImplicitAny` in tsconfig.json and rebuild', function (done) {
198201
this.timeout(420000);
199202

200-
var configFilePath = path.join(process.cwd(), 'src', 'tsconfig.json');
201-
fs.readFile(configFilePath, 'utf8', function(err, data){
202-
203-
var config = JSON.parse(data);
204-
config.compilerOptions.noImplicitAny = true;
205-
206-
fs.writeFile(configFilePath, JSON.stringify(config), function(){
207-
//clear the dist folder
208-
sh.rm('-rf', path.join(process.cwd(), 'dist'));
209-
210-
return ng([
211-
'build',
212-
'--silent'
213-
]).then(function() {
214-
expect(fs.existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
215-
})
216-
.finally(function(){
217-
// Clean `tmp` folder
218-
process.chdir(path.resolve(root, '..'));
219-
sh.rm('-rf', './tmp'); // tmp.teardown takes too long
220-
done();
221-
});
222-
});
223-
});
203+
const configFilePath = path.join(process.cwd(), 'src', 'tsconfig.json');
204+
let config = require(configFilePath);
205+
206+
config.compilerOptions.noImplicitAny = true;
207+
fs.writeFileSync(configFilePath, JSON.stringify(config), 'utf8');
208+
209+
sh.rm('-rf', path.join(process.cwd(), 'dist'));
210+
211+
return ng([
212+
'build',
213+
'--silent'
214+
]).then(function() {
215+
expect(fs.existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
216+
}).catch((err) => {
217+
throw new Error('Build failed.');
218+
})
219+
.finally(function(){
220+
// Clean `tmp` folder
221+
process.chdir(path.resolve(root, '..'));
222+
sh.rm('-rf', './tmp'); // tmp.teardown takes too long
223+
done();
224+
});
224225
});
225226

226227
});

0 commit comments

Comments
 (0)