Last active
May 7, 2025 06:46
-
-
Save osartun/d40a8f6d2b0b37bece376e974705beb6 to your computer and use it in GitHub Desktop.
Revisions
-
osartun revised this gist
Jun 17, 2021 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -30,14 +30,16 @@ const it = (name: string, cb: Function) => { /* Happy coding: */ const { expect } = require('chai') describe('My suite', () => { describe('My nested suite', () => { it('resolves successfully', () => { expect(true).to.equal(true); }) it('throws an error', () => { expect(true).to.equal(false); }) }) }) -
osartun created this gist
Jun 17, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ /** * You want to use mocha in a TypeScript CoderPad but you get the error * message that `describe` isn't defined even though you're already using * the `mocha.suite.emit('pre-require', this, 'solution', mocha)` hack? * * > Cannot find name 'describe'. Do you need to install type definitions * > for a test runner? Try `npm i --save-dev @types/jest` or * > `npm i --save-dev @types/mocha`. * * Here are a couple of lines to copy & paste into your pad to use * `describe` and `it`: */ const describe = (name: string, cb: Function) => { console.log(name); console.group(); cb(); console.groupEnd(); } const it = (name: string, cb: Function) => { try { cb(); console.log(`✅ ${name}`); } catch (e) { console.warn(`❌ ${name}`); console.error(e); } } /* Happy coding: */ describe('My suite', () => { describe('My nested suite', () => { it('returns', () => { // Do some assertions here }) it('throws', () => { throw new Error('Some problem occurred') }) }) })