-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Server): Add throwOnError behavior
- Loading branch information
1 parent
1bebddc
commit 2c3f42d
Showing
2 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Server} from '@'; | ||
|
||
const server = new Server(); | ||
|
||
describe('Errors management', function() { | ||
before(() => server.start()) | ||
beforeEach(() => server.reset()) | ||
after(() => server.stop()) | ||
|
||
describe('Server errors', function() { | ||
it('should be set to throw on error by default', async function() { | ||
try { | ||
await fetch(); | ||
expect.fail('Error not thrown'); | ||
} catch (err) { | ||
err.should.be.instanceof(Error); | ||
} | ||
}) | ||
|
||
it('should be set to respond with 500 error when failing', async function() { | ||
server.throwOnError(false); | ||
|
||
const response = await fetch(); | ||
|
||
response.status.should.equal(500); | ||
}) | ||
}) | ||
}) |