Skip to content

Instantly share code, notes, and snippets.

@juanpablocs
Created November 20, 2017 23:42
Show Gist options
  • Save juanpablocs/48e02c8e20b22e625a4f3a784647eb3a to your computer and use it in GitHub Desktop.
Save juanpablocs/48e02c8e20b22e625a4f3a784647eb3a to your computer and use it in GitHub Desktop.

Test promise

describe('unittest', () => {
    test('the data is peanut butter', () => {
        function fetchData(){
            return new Promise((resolve,reject)=>{
                resolve('peanut butter');
            });
        }
        expect.assertions(1);
        return expect(fetchData()).resolves.toBe('peanut butter');
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment