Skip to content

Commit 6491f5b

Browse files
authored
Merge pull request #10 from hexlet-basics/vitest
update tests
2 parents 8a2c2ab + 227e2e5 commit 6491f5b

File tree

105 files changed

+7501
-11308
lines changed

Some content is hidden

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

105 files changed

+7501
-11308
lines changed

Dockerfile

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
FROM hexletbasics/base-image
22

3-
WORKDIR /exercises-pre-course-javascript
4-
5-
COPY . .
6-
73
ENV NODE_PATH /exercises-pre-course-javascript/src
4+
ENV PATH=/exercises-pre-course-javascript/bin:$PATH
85

6+
WORKDIR /exercises-pre-course-javascript
7+
8+
RUN npm i -g vitest
9+
COPY package.json package-lock.json ./
910
RUN npm ci
1011

11-
ENV PATH=/exercises-pre-course-javascript/bin:$PATH
12+
COPY . .

bin/test2.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
FORCE_COLOR=1 vitest related --run `pwd`/test.js

eslint.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
5+
6+
/** @type {import('eslint').Linter.Config[]} */
7+
export default [
8+
{files: ["**/*.{js,mjs,cjs,ts}"]},
9+
{languageOptions: { globals: globals.browser }},
10+
pluginJs.configs.recommended,
11+
...tseslint.configs.recommended,
12+
];
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// @ts-check
22

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

55
const expected = 'Hello, World!';
6-
expectOutput(expected);
6+
7+
test('hello world', async () => {
8+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
9+
await import('./index.js')
10+
11+
const firstArg = consoleLogSpy.mock.calls.join('\n');
12+
13+
expect(firstArg).toBe(expected)
14+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// @ts-check
22

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

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

modules/10-basics/45-testing/Makefile

+1-1
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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '9780262531962';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = 'What Is Dead May Never Die';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '9';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '87';
4-
expectOutput(expected);
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(expected)
12+
})
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '243\n2';
4-
expectOutput(expected);
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(expected)
12+
})
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '10.5';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '49';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = 0.39 * 0.22;
4-
expectOutput(expected);
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[0]?.[0];
10+
11+
expect(firstArg).toBe(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = Infinity;
4-
expectOutput(expected);
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[0]?.[0];
10+
11+
expect(firstArg).toBe(expected)
12+
})
+1-1
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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = 'NaN';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '4';
4-
expectOutput(expected);
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(expected)
12+
})

modules/25-strings/10-quotes/Makefile

+1-1
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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = "\"Khal Drogo's favorite word is \"athjahakar\"\"";
4-
expectOutput(expected);
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(expected)
12+
})
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '- Did Joffrey agree?\n- He did. He also said "I love using \\n".';
4-
expectOutput(expected);
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(expected)
12+
})
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = 'Winter came for the House of Frey.';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = '~\n^\n%';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { expectOutput } from 'hexlet-basics/tests';
1+
import { expect, test, vi } from 'vitest'
22

33
const expected = 'What Is Dead May Never Die!';
4-
expectOutput(expected);
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(expected)
12+
})
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
test:
2-
@ test-output.sh
2+
@ test2.sh

0 commit comments

Comments
 (0)