Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 18859bc

Browse files
committedJan 8, 2025··
init using vitest
Signed-off-by: Kirill Mokevnin <[email protected]>
1 parent cf1352d commit 18859bc

File tree

11 files changed

+9271
-11846
lines changed

11 files changed

+9271
-11846
lines changed
 

‎Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
FROM hexletbasics/base-image
22

3-
ENV NODE_PATH /exercises-javascript/src
3+
ENV NODE_PATH=/exercises-javascript/src
44
ENV PATH=/exercises-javascript/bin:$PATH
55

66
WORKDIR /exercises-javascript
77

8+
RUN npm i -g vitest
89
COPY package.json package-lock.json ./
910
RUN npm ci
1011

‎Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ compose-schema-validate:
2929
ci-check:
3030
docker-compose --file docker-compose.yml build
3131
docker-compose --file docker-compose.yml up --abort-on-container-exit
32+
33+
docker-build-original:
34+
docker buildx build -t hexletbasics/exercises-javascript .

‎bin/test2.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FORCE_COLOR=1 vitest related --run `pwd`/test.js
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
// @ts-check
1+
import { expect, test, vi } from 'vitest'
22

3-
import { expectOutput } from 'hexlet-basics/tests';
3+
test('hello world', async () => {
4+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
5+
// @ts-ignore
6+
await import('./index.js')
47

5-
const expected = 'Hello, World!';
6-
expectOutput(expected);
8+
const firstArg = consoleLogSpy.mock.calls[0]?.[0];
9+
10+
expect(firstArg).toBe('Hello, World!')
11+
})

‎modules/50-loops/70-for/Makefile

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

‎modules/50-loops/70-for/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@jest/globals';
1+
import { expect, test } from 'vitest'
22
import f from './index.js';
33

44
test('test', () => {

‎package-lock.json

Lines changed: 9243 additions & 11836 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"expect": "^27.5.1",
2828
"jest": "^27.5.1",
2929
"lodash": "^4.17.21",
30-
"stacktracey": "^2.1.8"
30+
"stacktracey": "^2.1.8",
31+
"vitest": "^2.1.8"
3132
}
3233
}

‎src/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-check
2-
// TODO switch to the jest when it will works with modules
2+
// TODO use vitest
33

44
import expect from 'expect';
55
import chalk from 'chalk';

‎vitest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['**/*.test.js', '**/*.spec.js', '**/test.js'],
6+
},
7+
})

0 commit comments

Comments
 (0)
Please sign in to comment.