Created
April 28, 2023 18:57
-
-
Save epreston/e87a8ab2850e809412a4374615b092e5 to your computer and use it in GitHub Desktop.
vitest - example sanity test for test environment
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
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; | |
// --------------------------------------------------------- | |
describe('test environment', () => { | |
it('is working as expected', () => { | |
const obj = {}; | |
expect(obj).toBeDefined(); | |
expect(true).toBeTruthy(); | |
}); | |
it('defines vitest in the import.meta', () => { | |
expect(import.meta.vitest).toBeDefined(); | |
}); | |
}); | |
// --------------------------------------------------------- | |
describe('type check', () => { | |
it('should be type string', () => { | |
expect(typeof '').toBe('string'); | |
}); | |
it('should be type number', () => { | |
expect(typeof 10).toBe('number'); | |
}); | |
it('should be type boolean', () => { | |
expect(typeof true).toBe('boolean'); | |
}); | |
it('should be type undefined', () => { | |
expect(typeof undefined).toBe('undefined'); | |
}); | |
it('should be type object', () => { | |
expect(typeof { foo: 'bar' }).toBe('object'); | |
}); | |
it('should be type function', () => { | |
expect(typeof function () {}).toBe('function'); | |
}); | |
it('should be type null', () => { | |
expect(typeof null).toBe('object'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment