Skip to content

Commit 85fce30

Browse files
authored
Merge pull request #319 from hexlet-basics/vitest-exerices
Vitest exerices
2 parents 312cb3c + 18a2087 commit 85fce30

File tree

124 files changed

+2378
-5349
lines changed

Some content is hidden

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

124 files changed

+2378
-5349
lines changed

Dockerfile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
FROM hexletbasics/base-image:latest
22

3-
WORKDIR /exercises-typescript
4-
5-
COPY package.json .
3+
ENV PATH=/exercises-typescript/bin:/exercises-typescript/node_modules/.bin:$PATH
4+
# ENV NODE_OPTIONS --max-old-space-size=4096
5+
# --experimental-vm-modules
6+
ENV CI=true
67

7-
COPY package-lock.json .
8+
WORKDIR /exercises-typescript
89

9-
RUN npm install
10+
RUN npm i -g vitest
11+
COPY package.json package-lock.json ./
12+
RUN npm ci
1013

1114
COPY . .
12-
13-
ENV PATH /exercises-typescript/bin:/exercises-typescript/node_modules/.bin:$PATH
14-
# ENV NODE_OPTIONS --max-old-space-size=4096
15-
# --experimental-vm-modules
16-
ENV CI true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ ci-check:
4141
docker compose --file docker-compose.yml up --abort-on-container-exit
4242

4343
test-fast:
44-
npx jest
44+
npx vitest

bin/test2.sh

Lines changed: 3 additions & 0 deletions
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.ts

eslint.config.js

Lines changed: 12 additions & 0 deletions
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+
];

jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.
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
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { expect, test, vi } from 'vitest'
12
import * as path from 'path';
2-
import * as sinon from 'sinon';
33

44
test('hello world', async () => {
5-
const spy = sinon.spy(console, 'log');
5+
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => { });
66
await import(path.join(__dirname, 'index'));
7-
sinon.assert.calledWith(spy, 'Hello, World!');
7+
const firstArg = consoleLogSpy.mock.calls[0]?.[0];
8+
expect(firstArg).toBe('Hello, World!')
89
});
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/10-basics/20-typescript-as-a-second-language/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
1+
22

33
// BEGIN
44
function multiply(a: number, b: number) {

modules/10-basics/20-typescript-as-a-second-language/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as ta from 'type-assertions';
2+
import { expect, test } from 'vitest';
23

34
import multiply from './index';
45

0 commit comments

Comments
 (0)