basic.test.ts 476 B

123456789101112131415161718192021
  1. import { assert, expect, test } from 'vitest';
  2. // Edit an assertion and save to see HMR in action
  3. test('Math.sqrt()', () => {
  4. expect(Math.sqrt(4)).toBe(2);
  5. expect(Math.sqrt(144)).toBe(12);
  6. expect(Math.sqrt(2)).toBe(Math.SQRT2);
  7. });
  8. test('JSON', () => {
  9. const input = {
  10. foo: 'hello',
  11. bar: 'world',
  12. };
  13. const output = JSON.stringify(input);
  14. expect(output).eq('{"foo":"hello","bar":"world"}');
  15. assert.deepEqual(JSON.parse(output), input, 'matches original');
  16. });