diff --git a/modules/10-basics/10-hello-world/test.js b/modules/10-basics/10-hello-world/test.js index de2521d9..27c42c04 100644 --- a/modules/10-basics/10-hello-world/test.js +++ b/modules/10-basics/10-hello-world/test.js @@ -1,10 +1,12 @@ +// @ts-check + import { expect, test, vi } from 'vitest' test('hello world', async () => { const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); await import('./index.js') - const firstArg = consoleLogSpy.mock.calls[0]?.[0]; + const firstArg = consoleLogSpy.mock.calls.join('\n'); expect(firstArg).toBe('Hello, World!') }) diff --git a/modules/10-basics/20-comments/Makefile b/modules/10-basics/20-comments/Makefile index 24e31e38..990011b4 100644 --- a/modules/10-basics/20-comments/Makefile +++ b/modules/10-basics/20-comments/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/10-basics/40-instructions/Makefile b/modules/10-basics/40-instructions/Makefile index 24e31e38..990011b4 100644 --- a/modules/10-basics/40-instructions/Makefile +++ b/modules/10-basics/40-instructions/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/10-basics/40-instructions/test.js b/modules/10-basics/40-instructions/test.js index 4f84cd39..de722a30 100644 --- a/modules/10-basics/40-instructions/test.js +++ b/modules/10-basics/40-instructions/test.js @@ -1,6 +1,12 @@ // @ts-check -import { expectOutput } from 'hexlet-basics/tests'; +import { expect, test, vi } from 'vitest' -const expected = 'Robert\nStannis\nRenly'; -expectOutput(expected); +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Robert\nStannis\nRenly') +}) diff --git a/modules/10-basics/45-testing/Makefile b/modules/10-basics/45-testing/Makefile index 24e31e38..990011b4 100644 --- a/modules/10-basics/45-testing/Makefile +++ b/modules/10-basics/45-testing/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/10-basics/45-testing/test.js b/modules/10-basics/45-testing/test.js index f5ae5628..4006ce67 100644 --- a/modules/10-basics/45-testing/test.js +++ b/modules/10-basics/45-testing/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '9780262531962'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('9780262531962') +}) diff --git a/modules/10-basics/50-syntax-errors/Makefile b/modules/10-basics/50-syntax-errors/Makefile index 24e31e38..990011b4 100644 --- a/modules/10-basics/50-syntax-errors/Makefile +++ b/modules/10-basics/50-syntax-errors/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/10-basics/50-syntax-errors/test.js b/modules/10-basics/50-syntax-errors/test.js index 619a8ad3..70221e16 100644 --- a/modules/10-basics/50-syntax-errors/test.js +++ b/modules/10-basics/50-syntax-errors/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'What Is Dead May Never Die'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('What Is Dead May Never Die') +}) diff --git a/modules/20-arithmetics/20-basic/Makefile b/modules/20-arithmetics/20-basic/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/20-basic/Makefile +++ b/modules/20-arithmetics/20-basic/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/20-basic/test.js b/modules/20-arithmetics/20-basic/test.js index 381cdf63..c75b0ce2 100644 --- a/modules/20-arithmetics/20-basic/test.js +++ b/modules/20-arithmetics/20-basic/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '9'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('9') +}) diff --git a/modules/20-arithmetics/25-operator/Makefile b/modules/20-arithmetics/25-operator/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/25-operator/Makefile +++ b/modules/20-arithmetics/25-operator/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/25-operator/test.js b/modules/20-arithmetics/25-operator/test.js index 2a501d98..3a08b430 100644 --- a/modules/20-arithmetics/25-operator/test.js +++ b/modules/20-arithmetics/25-operator/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '87'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('87') +}) diff --git a/modules/20-arithmetics/27-commutativity/Makefile b/modules/20-arithmetics/27-commutativity/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/27-commutativity/Makefile +++ b/modules/20-arithmetics/27-commutativity/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/27-commutativity/test.js b/modules/20-arithmetics/27-commutativity/test.js index 878ca2a4..7f17fdec 100644 --- a/modules/20-arithmetics/27-commutativity/test.js +++ b/modules/20-arithmetics/27-commutativity/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '243\n2'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('243\n2') +}) diff --git a/modules/20-arithmetics/30-composition/Makefile b/modules/20-arithmetics/30-composition/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/30-composition/Makefile +++ b/modules/20-arithmetics/30-composition/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/30-composition/test.js b/modules/20-arithmetics/30-composition/test.js index d9a875ff..588c0883 100644 --- a/modules/20-arithmetics/30-composition/test.js +++ b/modules/20-arithmetics/30-composition/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '10.5'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('10.5') +}) diff --git a/modules/20-arithmetics/40-priority/Makefile b/modules/20-arithmetics/40-priority/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/40-priority/Makefile +++ b/modules/20-arithmetics/40-priority/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/40-priority/test.js b/modules/20-arithmetics/40-priority/test.js index c492b7d8..b9c8fd22 100644 --- a/modules/20-arithmetics/40-priority/test.js +++ b/modules/20-arithmetics/40-priority/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '49'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('49') +}) diff --git a/modules/20-arithmetics/50-float/Makefile b/modules/20-arithmetics/50-float/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/50-float/Makefile +++ b/modules/20-arithmetics/50-float/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/50-float/test.js b/modules/20-arithmetics/50-float/test.js index aa62c30b..f935a52a 100644 --- a/modules/20-arithmetics/50-float/test.js +++ b/modules/20-arithmetics/50-float/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 0.39 * 0.22; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('0.0858') +}) diff --git a/modules/20-arithmetics/60-infinity/Makefile b/modules/20-arithmetics/60-infinity/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/60-infinity/Makefile +++ b/modules/20-arithmetics/60-infinity/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/60-infinity/test.js b/modules/20-arithmetics/60-infinity/test.js index 40ea4f4c..8439ee93 100644 --- a/modules/20-arithmetics/60-infinity/test.js +++ b/modules/20-arithmetics/60-infinity/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = Infinity; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Infinity') +}) diff --git a/modules/20-arithmetics/70-nan/Makefile b/modules/20-arithmetics/70-nan/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/70-nan/Makefile +++ b/modules/20-arithmetics/70-nan/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/70-nan/test.js b/modules/20-arithmetics/70-nan/test.js index d8c80665..150a763c 100644 --- a/modules/20-arithmetics/70-nan/test.js +++ b/modules/20-arithmetics/70-nan/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'NaN'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('NaN') +}) diff --git a/modules/20-arithmetics/80-linting/Makefile b/modules/20-arithmetics/80-linting/Makefile index 24e31e38..990011b4 100644 --- a/modules/20-arithmetics/80-linting/Makefile +++ b/modules/20-arithmetics/80-linting/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/20-arithmetics/80-linting/test.js b/modules/20-arithmetics/80-linting/test.js index 966127c3..9d4779bb 100644 --- a/modules/20-arithmetics/80-linting/test.js +++ b/modules/20-arithmetics/80-linting/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '4'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('4') +}) diff --git a/modules/25-strings/10-quotes/Makefile b/modules/25-strings/10-quotes/Makefile index 24e31e38..990011b4 100644 --- a/modules/25-strings/10-quotes/Makefile +++ b/modules/25-strings/10-quotes/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/25-strings/10-quotes/test.js b/modules/25-strings/10-quotes/test.js index db6228d6..675516e7 100644 --- a/modules/25-strings/10-quotes/test.js +++ b/modules/25-strings/10-quotes/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = "\"Khal Drogo's favorite word is \"athjahakar\"\""; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe("\"Khal Drogo's favorite word is \"athjahakar\"\"") +}) diff --git a/modules/25-strings/15-escape-characters/Makefile b/modules/25-strings/15-escape-characters/Makefile index 24e31e38..990011b4 100644 --- a/modules/25-strings/15-escape-characters/Makefile +++ b/modules/25-strings/15-escape-characters/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/25-strings/15-escape-characters/test.js b/modules/25-strings/15-escape-characters/test.js index 0a14103b..6cbfd310 100644 --- a/modules/25-strings/15-escape-characters/test.js +++ b/modules/25-strings/15-escape-characters/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '- Did Joffrey agree?\n- He did. He also said "I love using \\n".'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('- Did Joffrey agree?\n- He did. He also said "I love using \\n".') +}) diff --git a/modules/25-strings/20-string-concatenation/Makefile b/modules/25-strings/20-string-concatenation/Makefile index 24e31e38..990011b4 100644 --- a/modules/25-strings/20-string-concatenation/Makefile +++ b/modules/25-strings/20-string-concatenation/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/25-strings/20-string-concatenation/test.js b/modules/25-strings/20-string-concatenation/test.js index fc9bd95e..f8ed0287 100644 --- a/modules/25-strings/20-string-concatenation/test.js +++ b/modules/25-strings/20-string-concatenation/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'Winter came for the House of Frey.'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Winter came for the House of Frey.') +}) diff --git a/modules/25-strings/30-encoding/Makefile b/modules/25-strings/30-encoding/Makefile index 24e31e38..990011b4 100644 --- a/modules/25-strings/30-encoding/Makefile +++ b/modules/25-strings/30-encoding/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/25-strings/30-encoding/test.js b/modules/25-strings/30-encoding/test.js index 51333beb..00f359d8 100644 --- a/modules/25-strings/30-encoding/test.js +++ b/modules/25-strings/30-encoding/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '~\n^\n%'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('~\n^\n%') +}) diff --git a/modules/30-variables/10-definition/Makefile b/modules/30-variables/10-definition/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/10-definition/Makefile +++ b/modules/30-variables/10-definition/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/10-definition/test.js b/modules/30-variables/10-definition/test.js index 9d80fc44..a1ed5867 100644 --- a/modules/30-variables/10-definition/test.js +++ b/modules/30-variables/10-definition/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'What Is Dead May Never Die!'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('What Is Dead May Never Die!') +}) diff --git a/modules/30-variables/11-change/Makefile b/modules/30-variables/11-change/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/11-change/Makefile +++ b/modules/30-variables/11-change/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/11-change/test.js b/modules/30-variables/11-change/test.js index 4273a44e..6252d0b4 100644 --- a/modules/30-variables/11-change/test.js +++ b/modules/30-variables/11-change/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'anneirB'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('anneirB') +}) diff --git a/modules/30-variables/13-variables-naming/Makefile b/modules/30-variables/13-variables-naming/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/13-variables-naming/Makefile +++ b/modules/30-variables/13-variables-naming/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/13-variables-naming/test.js b/modules/30-variables/13-variables-naming/test.js index 99a68d06..4f2bee70 100644 --- a/modules/30-variables/13-variables-naming/test.js +++ b/modules/30-variables/13-variables-naming/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 2; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('2') +}) diff --git a/modules/30-variables/14-errors/Makefile b/modules/30-variables/14-errors/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/14-errors/Makefile +++ b/modules/30-variables/14-errors/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/14-errors/test.js b/modules/30-variables/14-errors/test.js index d81cb661..43b50e6e 100644 --- a/modules/30-variables/14-errors/test.js +++ b/modules/30-variables/14-errors/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'Targaryen\nand\nDragon'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Targaryen\nand\nDragon') +}) diff --git a/modules/30-variables/15-variables-expressions/Makefile b/modules/30-variables/15-variables-expressions/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/15-variables-expressions/Makefile +++ b/modules/30-variables/15-variables-expressions/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/15-variables-expressions/test.js b/modules/30-variables/15-variables-expressions/test.js index 047eeb6d..8fd0faac 100644 --- a/modules/30-variables/15-variables-expressions/test.js +++ b/modules/30-variables/15-variables-expressions/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '125\n863.75'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('125\n863.75') +}) diff --git a/modules/30-variables/18-variable-concatenation/Makefile b/modules/30-variables/18-variable-concatenation/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/18-variable-concatenation/Makefile +++ b/modules/30-variables/18-variable-concatenation/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/18-variable-concatenation/test.js b/modules/30-variables/18-variable-concatenation/test.js index 0da330f6..5b37a729 100644 --- a/modules/30-variables/18-variable-concatenation/test.js +++ b/modules/30-variables/18-variable-concatenation/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = "Hello, Joffrey!\nHere is important information about your account security.\nWe couldn't verify your mother's maiden name."; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe("Hello, Joffrey!\nHere is important information about your account security.\nWe couldn't verify your mother's maiden name.") +}) diff --git a/modules/30-variables/19-naming-style/Makefile b/modules/30-variables/19-naming-style/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/19-naming-style/Makefile +++ b/modules/30-variables/19-naming-style/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/19-naming-style/test.js b/modules/30-variables/19-naming-style/test.js index cabe1a0e..477fbbfb 100644 --- a/modules/30-variables/19-naming-style/test.js +++ b/modules/30-variables/19-naming-style/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '-1100'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('-1100') +}) diff --git a/modules/30-variables/20-magic-numbers/Makefile b/modules/30-variables/20-magic-numbers/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/20-magic-numbers/Makefile +++ b/modules/30-variables/20-magic-numbers/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/20-magic-numbers/test.js b/modules/30-variables/20-magic-numbers/test.js index cd0739cc..c1632ed1 100644 --- a/modules/30-variables/20-magic-numbers/test.js +++ b/modules/30-variables/20-magic-numbers/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'King Balon the 6th has 102 rooms.'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('King Balon the 6th has 102 rooms.') +}) diff --git a/modules/30-variables/23-constants/Makefile b/modules/30-variables/23-constants/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/23-constants/Makefile +++ b/modules/30-variables/23-constants/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/23-constants/test.js b/modules/30-variables/23-constants/test.js index e04450c0..4c61c94b 100644 --- a/modules/30-variables/23-constants/test.js +++ b/modules/30-variables/23-constants/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'the white walkers'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('the white walkers') +}) diff --git a/modules/30-variables/25-interpolation/Makefile b/modules/30-variables/25-interpolation/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/25-interpolation/Makefile +++ b/modules/30-variables/25-interpolation/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/25-interpolation/test.js b/modules/30-variables/25-interpolation/test.js index 16ffdd25..db43d720 100644 --- a/modules/30-variables/25-interpolation/test.js +++ b/modules/30-variables/25-interpolation/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'Do you want to eat, Arya?'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Do you want to eat, Arya?') +}) diff --git a/modules/30-variables/30-symbols/Makefile b/modules/30-variables/30-symbols/Makefile index 24e31e38..990011b4 100644 --- a/modules/30-variables/30-symbols/Makefile +++ b/modules/30-variables/30-symbols/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/30-variables/30-symbols/test.js b/modules/30-variables/30-symbols/test.js index 2fcf9ab1..a6023ce0 100644 --- a/modules/30-variables/30-symbols/test.js +++ b/modules/30-variables/30-symbols/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 's'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('s') +}) diff --git a/modules/33-data-types/10-primitive-data-types/Makefile b/modules/33-data-types/10-primitive-data-types/Makefile index 24e31e38..990011b4 100644 --- a/modules/33-data-types/10-primitive-data-types/Makefile +++ b/modules/33-data-types/10-primitive-data-types/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/33-data-types/10-primitive-data-types/test.js b/modules/33-data-types/10-primitive-data-types/test.js index 1c3811e4..599e52e7 100644 --- a/modules/33-data-types/10-primitive-data-types/test.js +++ b/modules/33-data-types/10-primitive-data-types/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '-0.304'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('-0.304') +}) diff --git a/modules/33-data-types/45-undefined/Makefile b/modules/33-data-types/45-undefined/Makefile index 24e31e38..990011b4 100644 --- a/modules/33-data-types/45-undefined/Makefile +++ b/modules/33-data-types/45-undefined/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/33-data-types/45-undefined/test.js b/modules/33-data-types/45-undefined/test.js index 067ab668..3ea9d796 100644 --- a/modules/33-data-types/45-undefined/test.js +++ b/modules/33-data-types/45-undefined/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'undefined'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls[0]?.[0]; + + expect(firstArg).toBe(undefined) +}) diff --git a/modules/33-data-types/47-data-types-immutability/Makefile b/modules/33-data-types/47-data-types-immutability/Makefile index 24e31e38..990011b4 100644 --- a/modules/33-data-types/47-data-types-immutability/Makefile +++ b/modules/33-data-types/47-data-types-immutability/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/33-data-types/47-data-types-immutability/test.js b/modules/33-data-types/47-data-types-immutability/test.js index 0adc65ba..d2dd7198 100644 --- a/modules/33-data-types/47-data-types-immutability/test.js +++ b/modules/33-data-types/47-data-types-immutability/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'hodor'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('hodor') +}) diff --git a/modules/33-data-types/50-data-types-weak-typing/Makefile b/modules/33-data-types/50-data-types-weak-typing/Makefile index 24e31e38..990011b4 100644 --- a/modules/33-data-types/50-data-types-weak-typing/Makefile +++ b/modules/33-data-types/50-data-types-weak-typing/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/33-data-types/50-data-types-weak-typing/test.js b/modules/33-data-types/50-data-types-weak-typing/test.js index 4b272e4e..a4770a34 100644 --- a/modules/33-data-types/50-data-types-weak-typing/test.js +++ b/modules/33-data-types/50-data-types-weak-typing/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '13'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('13') +}) diff --git a/modules/35-calling-functions/100-call/Makefile b/modules/35-calling-functions/100-call/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/100-call/Makefile +++ b/modules/35-calling-functions/100-call/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/100-call/test.js b/modules/35-calling-functions/100-call/test.js index 7e897146..e5b120e8 100644 --- a/modules/35-calling-functions/100-call/test.js +++ b/modules/35-calling-functions/100-call/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '12'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('12') +}) diff --git a/modules/35-calling-functions/110-math/Makefile b/modules/35-calling-functions/110-math/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/110-math/Makefile +++ b/modules/35-calling-functions/110-math/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/110-math/test.js b/modules/35-calling-functions/110-math/test.js index dd5540a4..12b4f659 100644 --- a/modules/35-calling-functions/110-math/test.js +++ b/modules/35-calling-functions/110-math/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '2309'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('2309') +}) diff --git a/modules/35-calling-functions/120-function-signature/Makefile b/modules/35-calling-functions/120-function-signature/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/120-function-signature/Makefile +++ b/modules/35-calling-functions/120-function-signature/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/120-function-signature/test.js b/modules/35-calling-functions/120-function-signature/test.js index 9abfe291..285deefe 100644 --- a/modules/35-calling-functions/120-function-signature/test.js +++ b/modules/35-calling-functions/120-function-signature/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 924; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('924') +}) diff --git a/modules/35-calling-functions/135-calling-functions-default-arguments/Makefile b/modules/35-calling-functions/135-calling-functions-default-arguments/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/135-calling-functions-default-arguments/Makefile +++ b/modules/35-calling-functions/135-calling-functions-default-arguments/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/135-calling-functions-default-arguments/test.js b/modules/35-calling-functions/135-calling-functions-default-arguments/test.js index 4d2c1fe1..3205f1f4 100644 --- a/modules/35-calling-functions/135-calling-functions-default-arguments/test.js +++ b/modules/35-calling-functions/135-calling-functions-default-arguments/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '10.12'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('10.12') +}) diff --git a/modules/35-calling-functions/150-calling-functions-expression/Makefile b/modules/35-calling-functions/150-calling-functions-expression/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/150-calling-functions-expression/Makefile +++ b/modules/35-calling-functions/150-calling-functions-expression/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/150-calling-functions-expression/test.js b/modules/35-calling-functions/150-calling-functions-expression/test.js index 24809fcf..ac96751b 100644 --- a/modules/35-calling-functions/150-calling-functions-expression/test.js +++ b/modules/35-calling-functions/150-calling-functions-expression/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'First: N\nLast: t'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('First: N\nLast: t') +}) diff --git a/modules/35-calling-functions/180-variadic-parameters/Makefile b/modules/35-calling-functions/180-variadic-parameters/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/180-variadic-parameters/Makefile +++ b/modules/35-calling-functions/180-variadic-parameters/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/180-variadic-parameters/test.js b/modules/35-calling-functions/180-variadic-parameters/test.js index 933a99d0..7d0baf21 100644 --- a/modules/35-calling-functions/180-variadic-parameters/test.js +++ b/modules/35-calling-functions/180-variadic-parameters/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '-3'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('-3') +}) diff --git a/modules/35-calling-functions/270-deterministic/Makefile b/modules/35-calling-functions/270-deterministic/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/270-deterministic/Makefile +++ b/modules/35-calling-functions/270-deterministic/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/270-deterministic/test.js b/modules/35-calling-functions/270-deterministic/test.js index 7681c49f..dcf272b8 100644 --- a/modules/35-calling-functions/270-deterministic/test.js +++ b/modules/35-calling-functions/270-deterministic/test.js @@ -1,11 +1,16 @@ // @ts-check -import { expectOutput, expect } from 'hexlet-basics/tests'; +import { expect, test, vi } from 'vitest' -expectOutput((content) => { - expect(content).not.toEqual(''); - const value = Number(content); +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).not.toEqual(''); + const value = Number(firstArg); expect(Number.isInteger(value)).toEqual(true); expect(value).toBeGreaterThanOrEqual(0); expect(value).toBeLessThanOrEqual(10); -}); +}) diff --git a/modules/35-calling-functions/350-stdlib/Makefile b/modules/35-calling-functions/350-stdlib/Makefile index 24e31e38..990011b4 100644 --- a/modules/35-calling-functions/350-stdlib/Makefile +++ b/modules/35-calling-functions/350-stdlib/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/35-calling-functions/350-stdlib/test.js b/modules/35-calling-functions/350-stdlib/test.js index af8731e2..182788a2 100644 --- a/modules/35-calling-functions/350-stdlib/test.js +++ b/modules/35-calling-functions/350-stdlib/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'string'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('string') +}) diff --git a/modules/38-properties/100-properties-syntax/Makefile b/modules/38-properties/100-properties-syntax/Makefile index 24e31e38..990011b4 100644 --- a/modules/38-properties/100-properties-syntax/Makefile +++ b/modules/38-properties/100-properties-syntax/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/38-properties/100-properties-syntax/test.js b/modules/38-properties/100-properties-syntax/test.js index e596ef0d..2ad052f2 100644 --- a/modules/38-properties/100-properties-syntax/test.js +++ b/modules/38-properties/100-properties-syntax/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 75; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('75') +}) diff --git a/modules/38-properties/200-properties-methods/Makefile b/modules/38-properties/200-properties-methods/Makefile index 24e31e38..990011b4 100644 --- a/modules/38-properties/200-properties-methods/Makefile +++ b/modules/38-properties/200-properties-methods/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/38-properties/200-properties-methods/test.js b/modules/38-properties/200-properties-methods/test.js index 664a2368..f98c4736 100644 --- a/modules/38-properties/200-properties-methods/test.js +++ b/modules/38-properties/200-properties-methods/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'a mind needs books as a sword needs a whetstone, if it is to keep its edge.'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('a mind needs books as a sword needs a whetstone, if it is to keep its edge.') +}) diff --git a/modules/38-properties/300-properties-immutability/Makefile b/modules/38-properties/300-properties-immutability/Makefile index 24e31e38..990011b4 100644 --- a/modules/38-properties/300-properties-immutability/Makefile +++ b/modules/38-properties/300-properties-immutability/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/38-properties/300-properties-immutability/test.js b/modules/38-properties/300-properties-immutability/test.js index b2f2aa7a..128549d6 100644 --- a/modules/38-properties/300-properties-immutability/test.js +++ b/modules/38-properties/300-properties-immutability/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'Grigor'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Grigor') +}) diff --git a/modules/38-properties/400-properties-expressions/Makefile b/modules/38-properties/400-properties-expressions/Makefile index 24e31e38..990011b4 100644 --- a/modules/38-properties/400-properties-expressions/Makefile +++ b/modules/38-properties/400-properties-expressions/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/38-properties/400-properties-expressions/test.js b/modules/38-properties/400-properties-expressions/test.js index 24809fcf..ac96751b 100644 --- a/modules/38-properties/400-properties-expressions/test.js +++ b/modules/38-properties/400-properties-expressions/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'First: N\nLast: t'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('First: N\nLast: t') +}) diff --git a/modules/38-properties/500-properties-chain-of-methods/Makefile b/modules/38-properties/500-properties-chain-of-methods/Makefile index 24e31e38..990011b4 100644 --- a/modules/38-properties/500-properties-chain-of-methods/Makefile +++ b/modules/38-properties/500-properties-chain-of-methods/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/38-properties/500-properties-chain-of-methods/test.js b/modules/38-properties/500-properties-chain-of-methods/test.js index 51b1f77f..98dd8d4e 100644 --- a/modules/38-properties/500-properties-chain-of-methods/test.js +++ b/modules/38-properties/500-properties-chain-of-methods/test.js @@ -1,4 +1,12 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 7; -expectOutput(expected); +import { expect, test, vi } from 'vitest' + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + await import('./index.js') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('7') +}) diff --git a/modules/40-define-functions/100-define-functions-syntax/Makefile b/modules/40-define-functions/100-define-functions-syntax/Makefile index 24e31e38..990011b4 100644 --- a/modules/40-define-functions/100-define-functions-syntax/Makefile +++ b/modules/40-define-functions/100-define-functions-syntax/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/40-define-functions/100-define-functions-syntax/test.js b/modules/40-define-functions/100-define-functions-syntax/test.js index 9678890c..5e1e705d 100644 --- a/modules/40-define-functions/100-define-functions-syntax/test.js +++ b/modules/40-define-functions/100-define-functions-syntax/test.js @@ -1,4 +1,13 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 'Winter is coming'; -expectOutput(expected); +import { expect, test, vi } from 'vitest' +import f from './index.js'; + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + f() + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('Winter is coming') +}) diff --git a/modules/40-define-functions/150-define-functions-return/Makefile b/modules/40-define-functions/150-define-functions-return/Makefile index d0d0a48c..990011b4 100644 --- a/modules/40-define-functions/150-define-functions-return/Makefile +++ b/modules/40-define-functions/150-define-functions-return/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/40-define-functions/150-define-functions-return/test.js b/modules/40-define-functions/150-define-functions-return/test.js index 0b0e7ca6..4ff854ef 100644 --- a/modules/40-define-functions/150-define-functions-return/test.js +++ b/modules/40-define-functions/150-define-functions-return/test.js @@ -1,6 +1,6 @@ // @ts-check -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/40-define-functions/320-define-functions-parameters/Makefile b/modules/40-define-functions/320-define-functions-parameters/Makefile index d0d0a48c..990011b4 100644 --- a/modules/40-define-functions/320-define-functions-parameters/Makefile +++ b/modules/40-define-functions/320-define-functions-parameters/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/40-define-functions/320-define-functions-parameters/test.js b/modules/40-define-functions/320-define-functions-parameters/test.js index 9f1e6cf4..0adcef8a 100644 --- a/modules/40-define-functions/320-define-functions-parameters/test.js +++ b/modules/40-define-functions/320-define-functions-parameters/test.js @@ -1,6 +1,6 @@ // @ts-check -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/40-define-functions/340-define-functions-default-parameters/Makefile b/modules/40-define-functions/340-define-functions-default-parameters/Makefile index d0d0a48c..990011b4 100644 --- a/modules/40-define-functions/340-define-functions-default-parameters/Makefile +++ b/modules/40-define-functions/340-define-functions-default-parameters/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/40-define-functions/340-define-functions-default-parameters/test.js b/modules/40-define-functions/340-define-functions-default-parameters/test.js index 0bd6dabc..2bd1df4c 100644 --- a/modules/40-define-functions/340-define-functions-default-parameters/test.js +++ b/modules/40-define-functions/340-define-functions-default-parameters/test.js @@ -1,6 +1,6 @@ // @ts-check -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/40-define-functions/450-define-functions-short-syntax/Makefile b/modules/40-define-functions/450-define-functions-short-syntax/Makefile index d0d0a48c..990011b4 100644 --- a/modules/40-define-functions/450-define-functions-short-syntax/Makefile +++ b/modules/40-define-functions/450-define-functions-short-syntax/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/40-define-functions/450-define-functions-short-syntax/test.js b/modules/40-define-functions/450-define-functions-short-syntax/test.js index 948f783c..cd93f80e 100644 --- a/modules/40-define-functions/450-define-functions-short-syntax/test.js +++ b/modules/40-define-functions/450-define-functions-short-syntax/test.js @@ -1,6 +1,6 @@ // @ts-check -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/10-bool-type/Makefile b/modules/45-logic/10-bool-type/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/10-bool-type/Makefile +++ b/modules/45-logic/10-bool-type/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/10-bool-type/test.js b/modules/45-logic/10-bool-type/test.js index 83bfa071..59b7f622 100644 --- a/modules/45-logic/10-bool-type/test.js +++ b/modules/45-logic/10-bool-type/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/15-predicates/Makefile b/modules/45-logic/15-predicates/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/15-predicates/Makefile +++ b/modules/45-logic/15-predicates/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/15-predicates/test.js b/modules/45-logic/15-predicates/test.js index 0c7bdea2..6f789f1a 100644 --- a/modules/45-logic/15-predicates/test.js +++ b/modules/45-logic/15-predicates/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/20-logic-combine-expressions/Makefile b/modules/45-logic/20-logic-combine-expressions/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/20-logic-combine-expressions/Makefile +++ b/modules/45-logic/20-logic-combine-expressions/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/20-logic-combine-expressions/test.js b/modules/45-logic/20-logic-combine-expressions/test.js index b72ae092..95c637e1 100644 --- a/modules/45-logic/20-logic-combine-expressions/test.js +++ b/modules/45-logic/20-logic-combine-expressions/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/25-logical-operators/Makefile b/modules/45-logic/25-logical-operators/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/25-logical-operators/Makefile +++ b/modules/45-logic/25-logical-operators/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/25-logical-operators/test.js b/modules/45-logic/25-logical-operators/test.js index bb15b2fa..28dfffba 100644 --- a/modules/45-logic/25-logical-operators/test.js +++ b/modules/45-logic/25-logical-operators/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/28-logical-negation/Makefile b/modules/45-logic/28-logical-negation/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/28-logical-negation/Makefile +++ b/modules/45-logic/28-logical-negation/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/28-logical-negation/test.js b/modules/45-logic/28-logical-negation/test.js index 01799211..1e8047ba 100644 --- a/modules/45-logic/28-logical-negation/test.js +++ b/modules/45-logic/28-logical-negation/test.js @@ -1,6 +1,6 @@ // @ts-check -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/45-logic/70-logical-expressions/Makefile b/modules/45-logic/70-logical-expressions/Makefile index d0d0a48c..990011b4 100644 --- a/modules/45-logic/70-logical-expressions/Makefile +++ b/modules/45-logic/70-logical-expressions/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/45-logic/70-logical-expressions/test.js b/modules/45-logic/70-logical-expressions/test.js index b62d0888..ee6e81e3 100644 --- a/modules/45-logic/70-logical-expressions/test.js +++ b/modules/45-logic/70-logical-expressions/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/48-conditionals/30-if/Makefile b/modules/48-conditionals/30-if/Makefile index b7c38a92..943ecde3 100644 --- a/modules/48-conditionals/30-if/Makefile +++ b/modules/48-conditionals/30-if/Makefile @@ -1,3 +1,3 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/48-conditionals/30-if/test.js b/modules/48-conditionals/30-if/test.js index 13d4949e..64971bef 100644 --- a/modules/48-conditionals/30-if/test.js +++ b/modules/48-conditionals/30-if/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/48-conditionals/40-if-else/Makefile b/modules/48-conditionals/40-if-else/Makefile index d0d0a48c..990011b4 100644 --- a/modules/48-conditionals/40-if-else/Makefile +++ b/modules/48-conditionals/40-if-else/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/48-conditionals/40-if-else/test.js b/modules/48-conditionals/40-if-else/test.js index 3167ede0..b201ac70 100644 --- a/modules/48-conditionals/40-if-else/test.js +++ b/modules/48-conditionals/40-if-else/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/48-conditionals/50-else-if/Makefile b/modules/48-conditionals/50-else-if/Makefile index d0d0a48c..990011b4 100644 --- a/modules/48-conditionals/50-else-if/Makefile +++ b/modules/48-conditionals/50-else-if/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/48-conditionals/50-else-if/test.js b/modules/48-conditionals/50-else-if/test.js index 89143249..f212969e 100644 --- a/modules/48-conditionals/50-else-if/test.js +++ b/modules/48-conditionals/50-else-if/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/48-conditionals/60-ternary-operator/Makefile b/modules/48-conditionals/60-ternary-operator/Makefile index d0d0a48c..990011b4 100644 --- a/modules/48-conditionals/60-ternary-operator/Makefile +++ b/modules/48-conditionals/60-ternary-operator/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/48-conditionals/60-ternary-operator/test.js b/modules/48-conditionals/60-ternary-operator/test.js index 27ced3be..03875798 100644 --- a/modules/48-conditionals/60-ternary-operator/test.js +++ b/modules/48-conditionals/60-ternary-operator/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/48-conditionals/65-switch/Makefile b/modules/48-conditionals/65-switch/Makefile index d0d0a48c..990011b4 100644 --- a/modules/48-conditionals/65-switch/Makefile +++ b/modules/48-conditionals/65-switch/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/48-conditionals/65-switch/test.js b/modules/48-conditionals/65-switch/test.js index d1b283f6..e9f8b18c 100644 --- a/modules/48-conditionals/65-switch/test.js +++ b/modules/48-conditionals/65-switch/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/10-while/Makefile b/modules/50-loops/10-while/Makefile index 24e31e38..990011b4 100644 --- a/modules/50-loops/10-while/Makefile +++ b/modules/50-loops/10-while/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/50-loops/10-while/test.js b/modules/50-loops/10-while/test.js index 6e7dd0d2..d05d50b3 100644 --- a/modules/50-loops/10-while/test.js +++ b/modules/50-loops/10-while/test.js @@ -1,4 +1,13 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = '6\n5\n4\n3\n2\n1\nfinished!'; -expectOutput(expected, (f) => f(6)); +import { expect, test, vi } from 'vitest' +import f from './index.js'; + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + f(6); + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('6\n5\n4\n3\n2\n1\nfinished!') +}) diff --git a/modules/50-loops/20-aggregation-numbers/Makefile b/modules/50-loops/20-aggregation-numbers/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/20-aggregation-numbers/Makefile +++ b/modules/50-loops/20-aggregation-numbers/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/20-aggregation-numbers/test.js b/modules/50-loops/20-aggregation-numbers/test.js index 358506ba..f9c71448 100644 --- a/modules/50-loops/20-aggregation-numbers/test.js +++ b/modules/50-loops/20-aggregation-numbers/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/23-aggregation-strings/Makefile b/modules/50-loops/23-aggregation-strings/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/23-aggregation-strings/Makefile +++ b/modules/50-loops/23-aggregation-strings/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/23-aggregation-strings/test.js b/modules/50-loops/23-aggregation-strings/test.js index 57d2a677..fd5c355c 100644 --- a/modules/50-loops/23-aggregation-strings/test.js +++ b/modules/50-loops/23-aggregation-strings/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/25-iteration-over-string/Makefile b/modules/50-loops/25-iteration-over-string/Makefile index 24e31e38..990011b4 100644 --- a/modules/50-loops/25-iteration-over-string/Makefile +++ b/modules/50-loops/25-iteration-over-string/Makefile @@ -1,2 +1,2 @@ test: - @ test-output.sh + @ test2.sh diff --git a/modules/50-loops/25-iteration-over-string/test.js b/modules/50-loops/25-iteration-over-string/test.js index d2753348..e6c0226d 100644 --- a/modules/50-loops/25-iteration-over-string/test.js +++ b/modules/50-loops/25-iteration-over-string/test.js @@ -1,4 +1,13 @@ -import { expectOutput } from 'hexlet-basics/tests'; +// @ts-check -const expected = 't\ne\nl\nx\ne\nH'; -expectOutput(expected, (f) => f('Hexlet')); +import { expect, test, vi } from 'vitest' +import f from './index.js'; + +test('hello world', async () => { + const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { }); + f('Hexlet') + + const firstArg = consoleLogSpy.mock.calls.join('\n'); + + expect(firstArg).toBe('t\ne\nl\nx\ne\nH') +}) diff --git a/modules/50-loops/26-conditions-inside-loops/Makefile b/modules/50-loops/26-conditions-inside-loops/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/26-conditions-inside-loops/Makefile +++ b/modules/50-loops/26-conditions-inside-loops/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/26-conditions-inside-loops/test.js b/modules/50-loops/26-conditions-inside-loops/test.js index 5f6ce00e..2b45c92e 100644 --- a/modules/50-loops/26-conditions-inside-loops/test.js +++ b/modules/50-loops/26-conditions-inside-loops/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/28-build-strings/Makefile b/modules/50-loops/28-build-strings/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/28-build-strings/Makefile +++ b/modules/50-loops/28-build-strings/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/28-build-strings/test.js b/modules/50-loops/28-build-strings/test.js index 4af85ab7..071742cd 100644 --- a/modules/50-loops/28-build-strings/test.js +++ b/modules/50-loops/28-build-strings/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/30-syntax-sugar/Makefile b/modules/50-loops/30-syntax-sugar/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/30-syntax-sugar/Makefile +++ b/modules/50-loops/30-syntax-sugar/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/30-syntax-sugar/test.js b/modules/50-loops/30-syntax-sugar/test.js index 496b8444..34f3704e 100644 --- a/modules/50-loops/30-syntax-sugar/test.js +++ b/modules/50-loops/30-syntax-sugar/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/50-mutators/Makefile b/modules/50-loops/50-mutators/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/50-mutators/Makefile +++ b/modules/50-loops/50-mutators/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/50-mutators/test.js b/modules/50-loops/50-mutators/test.js index ed01b637..7843897f 100644 --- a/modules/50-loops/50-mutators/test.js +++ b/modules/50-loops/50-mutators/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/modules/50-loops/55-return-from-loops/Makefile b/modules/50-loops/55-return-from-loops/Makefile index d0d0a48c..990011b4 100644 --- a/modules/50-loops/55-return-from-loops/Makefile +++ b/modules/50-loops/55-return-from-loops/Makefile @@ -1,2 +1,2 @@ test: - @ test.sh + @ test2.sh diff --git a/modules/50-loops/55-return-from-loops/test.js b/modules/50-loops/55-return-from-loops/test.js index 5fde2c44..e820bef3 100644 --- a/modules/50-loops/55-return-from-loops/test.js +++ b/modules/50-loops/55-return-from-loops/test.js @@ -1,4 +1,4 @@ -import { test, expect } from '@jest/globals'; +import { expect, test } from 'vitest'; import f from './index.js'; test('test', () => { diff --git a/src/tests.js b/src/tests.js index 37e0f5ee..098f0b2b 100644 --- a/src/tests.js +++ b/src/tests.js @@ -1,7 +1,7 @@ // @ts-check // TODO use vitest -import { expect } from 'expect'; +import { expect } from 'vitest' import chalk from 'chalk'; import StackTracey from 'stacktracey'; import _ from 'lodash';