Skip to content

Commit b19a593

Browse files
authored
Merge pull request #774 from hexlet-basics/vitest
Vitest
2 parents e51faac + 0f16dc2 commit b19a593

File tree

141 files changed

+613
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+613
-237
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// @ts-check
2+
13
import { expect, test, vi } from 'vitest'
24

35
test('hello world', async () => {
46
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
57
await import('./index.js')
68

7-
const firstArg = consoleLogSpy.mock.calls[0]?.[0];
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
810

911
expect(firstArg).toBe('Hello, World!')
1012
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
// @ts-check
22

3-
import { expectOutput } from 'hexlet-basics/tests';
3+
import { expect, test, vi } from 'vitest'
44

5-
const expected = 'Robert\nStannis\nRenly';
6-
expectOutput(expected);
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('Robert\nStannis\nRenly')
12+
})

modules/10-basics/45-testing/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh

modules/10-basics/45-testing/test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '9780262531962';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('9780262531962')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 'What Is Dead May Never Die';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('What Is Dead May Never Die')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '9';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('9')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '87';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('87')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '243\n2';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('243\n2')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '10.5';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('10.5')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '49';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('49')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 0.39 * 0.22;
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('0.0858')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = Infinity;
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('Infinity')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh

modules/20-arithmetics/70-nan/test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 'NaN';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('NaN')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '4';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('4')
12+
})

modules/25-strings/10-quotes/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh

modules/25-strings/10-quotes/test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = "\"Khal Drogo's favorite word is \"athjahakar\"\"";
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe("\"Khal Drogo's favorite word is \"athjahakar\"\"")
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '- Did Joffrey agree?\n- He did. He also said "I love using \\n".';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('- Did Joffrey agree?\n- He did. He also said "I love using \\n".')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 'Winter came for the House of Frey.';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('Winter came for the House of Frey.')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = '~\n^\n%';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('~\n^\n%')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 'What Is Dead May Never Die!';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('What Is Dead May Never Die!')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 'anneirB';
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('anneirB')
12+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
// @ts-check
22

3-
const expected = 2;
4-
expectOutput(expected);
3+
import { expect, test, vi } from 'vitest'
4+
5+
test('hello world', async () => {
6+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
7+
await import('./index.js')
8+
9+
const firstArg = consoleLogSpy.mock.calls.join('\n');
10+
11+
expect(firstArg).toBe('2')
12+
})

0 commit comments

Comments
 (0)