diff --git a/examples/kitchen-sink/apps/api/package.json b/examples/kitchen-sink/apps/api/package.json index e6211fbf0e593..b62f2a2dc6a4b 100644 --- a/examples/kitchen-sink/apps/api/package.json +++ b/examples/kitchen-sink/apps/api/package.json @@ -22,13 +22,13 @@ "morgan": "^1.10.0" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@repo/eslint-config": "workspace:*", "@repo/jest-presets": "workspace:*", "@repo/typescript-config": "workspace:*", "@types/body-parser": "^1.19.5", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", - "@types/jest": "^29.5.13", "@types/morgan": "^1.9.9", "@types/node": "^20.11.24", "@types/supertest": "^6.0.2", diff --git a/examples/kitchen-sink/apps/api/src/__tests__/server.test.ts b/examples/kitchen-sink/apps/api/src/__tests__/server.test.ts index e72e8886e015f..8d0bb06b95ea2 100644 --- a/examples/kitchen-sink/apps/api/src/__tests__/server.test.ts +++ b/examples/kitchen-sink/apps/api/src/__tests__/server.test.ts @@ -1,4 +1,5 @@ import supertest from "supertest"; +import { describe, it, expect } from "@jest/globals"; import { createServer } from "../server"; describe("Server", () => { diff --git a/examples/kitchen-sink/packages/logger/package.json b/examples/kitchen-sink/packages/logger/package.json index af9cad0b0a0ea..8f796e3f5c46d 100644 --- a/examples/kitchen-sink/packages/logger/package.json +++ b/examples/kitchen-sink/packages/logger/package.json @@ -18,10 +18,10 @@ "preset": "@repo/jest-presets/node" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@repo/eslint-config": "workspace:*", "@repo/jest-presets": "workspace:*", "@repo/typescript-config": "workspace:*", - "@types/jest": "^29.5.13", "@types/node": "^20.11.24", "jest": "^29.7.0", "tsup": "^8.0.2", diff --git a/examples/kitchen-sink/packages/logger/src/__tests__/log.test.ts b/examples/kitchen-sink/packages/logger/src/__tests__/log.test.ts index e196fcc99f77b..55fd698fa28a9 100644 --- a/examples/kitchen-sink/packages/logger/src/__tests__/log.test.ts +++ b/examples/kitchen-sink/packages/logger/src/__tests__/log.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect, jest } from "@jest/globals"; import { log } from ".."; jest.spyOn(global.console, "log"); diff --git a/examples/kitchen-sink/packages/ui/package.json b/examples/kitchen-sink/packages/ui/package.json index 48675d54b5d1e..c071dad4460d8 100644 --- a/examples/kitchen-sink/packages/ui/package.json +++ b/examples/kitchen-sink/packages/ui/package.json @@ -31,10 +31,10 @@ "preset": "@repo/jest-presets/browser" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@repo/eslint-config": "workspace:*", "@repo/jest-presets": "workspace:*", "@repo/typescript-config": "workspace:*", - "@types/jest": "^29.5.13", "@types/node": "^20.11.24", "@types/react": "^18.2.62", "@types/react-dom": "^18.2.19", diff --git a/examples/kitchen-sink/packages/ui/src/counter-button/index.test.tsx b/examples/kitchen-sink/packages/ui/src/counter-button/index.test.tsx index fc548077c7b36..7e3a16b41403d 100644 --- a/examples/kitchen-sink/packages/ui/src/counter-button/index.test.tsx +++ b/examples/kitchen-sink/packages/ui/src/counter-button/index.test.tsx @@ -1,3 +1,4 @@ +import { describe, it } from "@jest/globals"; import { createRoot } from "react-dom/client"; import { CounterButton } from "."; diff --git a/examples/kitchen-sink/packages/ui/src/link/index.test.tsx b/examples/kitchen-sink/packages/ui/src/link/index.test.tsx index d1a954e8a79fd..82a2e1a8fb6cd 100644 --- a/examples/kitchen-sink/packages/ui/src/link/index.test.tsx +++ b/examples/kitchen-sink/packages/ui/src/link/index.test.tsx @@ -1,3 +1,4 @@ +import { describe, it } from "@jest/globals"; import { createRoot } from "react-dom/client"; import { Link } from "."; diff --git a/examples/kitchen-sink/pnpm-lock.yaml b/examples/kitchen-sink/pnpm-lock.yaml index 21c566fa0268d..94a3a6c4ce7f0 100644 --- a/examples/kitchen-sink/pnpm-lock.yaml +++ b/examples/kitchen-sink/pnpm-lock.yaml @@ -67,6 +67,9 @@ importers: specifier: ^1.10.0 version: 1.10.0 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@repo/eslint-config': specifier: workspace:* version: link:../../packages/config-eslint @@ -85,9 +88,6 @@ importers: '@types/express': specifier: ^4.17.21 version: 4.17.21 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/morgan': specifier: ^1.9.9 version: 1.9.9 @@ -249,6 +249,9 @@ importers: packages/logger: devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@repo/eslint-config': specifier: workspace:* version: link:../config-eslint @@ -258,9 +261,6 @@ importers: '@repo/typescript-config': specifier: workspace:* version: link:../config-typescript - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^20.11.24 version: 20.16.5 @@ -276,6 +276,9 @@ importers: packages/ui: devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@repo/eslint-config': specifier: workspace:* version: link:../config-eslint @@ -285,9 +288,6 @@ importers: '@repo/typescript-config': specifier: workspace:* version: link:../config-typescript - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^20.11.24 version: 20.16.5 @@ -2542,13 +2542,6 @@ packages: dependencies: '@types/istanbul-lib-report': 3.0.3 - /@types/jest@29.5.13: - resolution: {integrity: sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg==} - dependencies: - expect: 29.7.0 - pretty-format: 29.7.0 - dev: true - /@types/jsdom@20.0.1: resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} dependencies: diff --git a/examples/with-docker/apps/api/package.json b/examples/with-docker/apps/api/package.json index de0a9b1d7872e..ea10e6d1a55d9 100644 --- a/examples/with-docker/apps/api/package.json +++ b/examples/with-docker/apps/api/package.json @@ -21,13 +21,13 @@ "morgan": "^1.10.0" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@repo/eslint-config": "*", "@repo/jest-presets": "*", "@repo/typescript-config": "*", "@types/body-parser": "^1.19.5", "@types/cors": "^2.8.17", "@types/express": "^4.17.21", - "@types/jest": "^29.5.13", "@types/morgan": "^1.9.9", "@types/node": "^20.11.24", "@types/supertest": "^6.0.2", diff --git a/examples/with-docker/apps/api/src/__tests__/server.test.ts b/examples/with-docker/apps/api/src/__tests__/server.test.ts index 1385679fb36a5..55503bd86e8b4 100644 --- a/examples/with-docker/apps/api/src/__tests__/server.test.ts +++ b/examples/with-docker/apps/api/src/__tests__/server.test.ts @@ -1,4 +1,5 @@ import supertest from "supertest"; +import { describe, it, expect } from "@jest/globals"; import { createServer } from "../server"; describe("server", () => { diff --git a/examples/with-docker/packages/logger/package.json b/examples/with-docker/packages/logger/package.json index 6efd6552932b1..504e8e2f78fbb 100644 --- a/examples/with-docker/packages/logger/package.json +++ b/examples/with-docker/packages/logger/package.json @@ -18,10 +18,10 @@ "preset": "@repo/jest-presets/node" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@repo/eslint-config": "*", "@repo/jest-presets": "*", "@repo/typescript-config": "*", - "@types/jest": "^29.5.13", "@types/node": "^20.11.24", "eslint": "^8.57.0", "jest": "^29.7.0", diff --git a/examples/with-docker/packages/logger/src/__tests__/log.test.ts b/examples/with-docker/packages/logger/src/__tests__/log.test.ts index 0da12534d68e4..a31c4fc65c28d 100644 --- a/examples/with-docker/packages/logger/src/__tests__/log.test.ts +++ b/examples/with-docker/packages/logger/src/__tests__/log.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect, jest } from "@jest/globals"; import { log } from ".."; jest.spyOn(global.console, "log"); diff --git a/examples/with-docker/yarn.lock b/examples/with-docker/yarn.lock index 715548f13b954..ad143d2e1de25 100644 --- a/examples/with-docker/yarn.lock +++ b/examples/with-docker/yarn.lock @@ -988,14 +988,6 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^29.5.13": - version "29.5.13" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.13.tgz#8bc571659f401e6a719a7bf0dbcb8b78c71a8adc" - integrity sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg== - dependencies: - expect "^29.0.0" - pretty-format "^29.0.0" - "@types/json-schema@^7.0.12", "@types/json-schema@^7.0.9": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" @@ -2654,7 +2646,7 @@ exit@^0.1.2: resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== -expect@^29.0.0, expect@^29.7.0: +expect@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/expect/-/expect-29.7.0.tgz#578874590dcb3214514084c08115d8aee61e11bc" integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== @@ -4512,7 +4504,7 @@ prettier@^3.2.5: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== -pretty-format@^29.0.0, pretty-format@^29.7.0: +pretty-format@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ== diff --git a/examples/with-nestjs/apps/api/package.json b/examples/with-nestjs/apps/api/package.json index e79633a150d56..f4589ff52e97d 100644 --- a/examples/with-nestjs/apps/api/package.json +++ b/examples/with-nestjs/apps/api/package.json @@ -23,6 +23,7 @@ "rxjs": "^7.8.1" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", @@ -30,7 +31,6 @@ "@repo/jest-config": "workspace:*", "@repo/typescript-config": "workspace:*", "@types/express": "^4.17.17", - "@types/jest": "^29.5.13", "@types/node": "^20.3.1", "@types/supertest": "^6.0.0", "jest": "^29.7.0", diff --git a/examples/with-nestjs/apps/api/src/app.controller.spec.ts b/examples/with-nestjs/apps/api/src/app.controller.spec.ts index d22f3890a380c..939c4ac913396 100644 --- a/examples/with-nestjs/apps/api/src/app.controller.spec.ts +++ b/examples/with-nestjs/apps/api/src/app.controller.spec.ts @@ -1,4 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { describe, it, expect, beforeEach } from '@jest/globals'; import { AppController } from './app.controller'; import { AppService } from './app.service'; diff --git a/examples/with-nestjs/apps/api/src/links/links.controller.spec.ts b/examples/with-nestjs/apps/api/src/links/links.controller.spec.ts index fdff163822a7c..23368ce420c74 100644 --- a/examples/with-nestjs/apps/api/src/links/links.controller.spec.ts +++ b/examples/with-nestjs/apps/api/src/links/links.controller.spec.ts @@ -1,4 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { describe, it, expect, beforeEach } from '@jest/globals'; import { LinksController } from './links.controller'; import { LinksService } from './links.service'; diff --git a/examples/with-nestjs/apps/api/src/links/links.service.spec.ts b/examples/with-nestjs/apps/api/src/links/links.service.spec.ts index 7b1acd4266d9e..71cfcbccefb2f 100644 --- a/examples/with-nestjs/apps/api/src/links/links.service.spec.ts +++ b/examples/with-nestjs/apps/api/src/links/links.service.spec.ts @@ -1,4 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { describe, it, expect, beforeEach } from '@jest/globals'; import { LinksService } from './links.service'; describe('LinksService', () => { diff --git a/examples/with-nestjs/apps/api/test/app.e2e-spec.ts b/examples/with-nestjs/apps/api/test/app.e2e-spec.ts index 9ceebc4bec55a..6e55bca0066b1 100644 --- a/examples/with-nestjs/apps/api/test/app.e2e-spec.ts +++ b/examples/with-nestjs/apps/api/test/app.e2e-spec.ts @@ -1,5 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; +import { describe, it, beforeEach } from '@jest/globals'; import request from 'supertest'; import { AppModule } from './../src/app.module'; diff --git a/examples/with-nestjs/apps/web/package.json b/examples/with-nestjs/apps/web/package.json index ed38181e4de43..38ba0609562a1 100644 --- a/examples/with-nestjs/apps/web/package.json +++ b/examples/with-nestjs/apps/web/package.json @@ -18,6 +18,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@next/eslint-plugin-next": "^14.1.1", "@playwright/test": "^1.44.0", "@repo/api": "workspace:*", @@ -26,7 +27,6 @@ "@repo/typescript-config": "workspace:*", "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^15.0.7", - "@types/jest": "^29.5.13", "@types/node": "^20.11.24", "@types/react": "^18.2.61", "@types/react-dom": "^18.2.19", diff --git a/examples/with-nestjs/apps/web/test/layout.spec.tsx b/examples/with-nestjs/apps/web/test/layout.spec.tsx index 483ad004a088d..82d6383e775ea 100644 --- a/examples/with-nestjs/apps/web/test/layout.spec.tsx +++ b/examples/with-nestjs/apps/web/test/layout.spec.tsx @@ -1,4 +1,5 @@ import { metadata } from '../app/layout'; +import { describe, it, expect } from '@jest/globals'; describe('Root layout', () => { describe('metadata', () => { diff --git a/examples/with-nestjs/apps/web/test/page.spec.tsx b/examples/with-nestjs/apps/web/test/page.spec.tsx index b2128288ea258..56c1a40ee7fcc 100644 --- a/examples/with-nestjs/apps/web/test/page.spec.tsx +++ b/examples/with-nestjs/apps/web/test/page.spec.tsx @@ -1,4 +1,5 @@ import { render } from '@testing-library/react'; +import { describe, it, expect, jest, afterAll } from '@jest/globals'; import RootPage from '../app/page'; @@ -6,12 +7,12 @@ window.fetch = jest.fn().mockImplementation(() => Promise.resolve({ ok: true, json: () => [], - }), + }) ); describe('Root page', () => { const { container, unmount } = render( - , + ); it('should match the snapshot', () => { diff --git a/examples/with-nestjs/pnpm-lock.yaml b/examples/with-nestjs/pnpm-lock.yaml index d6a70d6e8f4f4..66349d4255a5d 100644 --- a/examples/with-nestjs/pnpm-lock.yaml +++ b/examples/with-nestjs/pnpm-lock.yaml @@ -42,6 +42,9 @@ importers: specifier: ^7.8.1 version: 7.8.1 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@nestjs/cli': specifier: ^10.0.0 version: 10.3.2 @@ -63,9 +66,6 @@ importers: '@types/express': specifier: ^4.17.17 version: 4.17.21 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^20.3.1 version: 20.11.24 @@ -112,6 +112,9 @@ importers: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@next/eslint-plugin-next': specifier: ^14.1.1 version: 14.1.1 @@ -132,13 +135,10 @@ importers: version: link:../../packages/typescript-config '@testing-library/jest-dom': specifier: ^6.4.5 - version: 6.4.5(@types/jest@29.5.13)(jest@29.7.0) + version: 6.4.5(@jest/globals@29.7.0)(jest@29.7.0) '@testing-library/react': specifier: ^15.0.7 version: 15.0.7(@types/react@18.2.61)(react-dom@18.2.0)(react@18.2.0) - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^20.11.24 version: 20.11.24 @@ -1410,7 +1410,7 @@ packages: pretty-format: 27.5.1 dev: true - /@testing-library/jest-dom@6.4.5(@types/jest@29.5.13)(jest@29.7.0): + /@testing-library/jest-dom@6.4.5(@jest/globals@29.7.0)(jest@29.7.0): resolution: {integrity: sha512-AguB9yvTXmCnySBP1lWjfNNUwpbElsaQ567lt2VdGqAdHtpieLgjmcVyv1q7PMIvLbgpDdkWV5Ydv3FEejyp2A==} engines: {node: '>=14', npm: '>=6', yarn: '>=1'} peerDependencies: @@ -1433,7 +1433,7 @@ packages: dependencies: '@adobe/css-tools': 4.3.3 '@babel/runtime': 7.23.2 - '@types/jest': 29.5.13 + '@jest/globals': 29.7.0 aria-query: 5.3.0 chalk: 3.0.0 css.escape: 1.5.1 @@ -1661,13 +1661,6 @@ packages: '@types/istanbul-lib-report': 3.0.3 dev: true - /@types/jest@29.5.13: - resolution: {integrity: sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg==} - dependencies: - expect: 29.7.0 - pretty-format: 29.7.0 - dev: true - /@types/jsdom@20.0.1: resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} dependencies: diff --git a/examples/with-typeorm/packages/typeorm-service/__test__/todo-service.test.ts b/examples/with-typeorm/packages/typeorm-service/__test__/todo-service.test.ts index ef9d484256852..a6731f1d8d4e4 100644 --- a/examples/with-typeorm/packages/typeorm-service/__test__/todo-service.test.ts +++ b/examples/with-typeorm/packages/typeorm-service/__test__/todo-service.test.ts @@ -1,4 +1,4 @@ -import { suite, expect, test, beforeEach, vi } from "vitest"; +import { suite, expect, it, beforeEach, vi } from "vitest"; import { TodoService } from "../src/domain/todo/todo.service"; import { TodoRepository } from "../src/domain/todo/todo.repository"; import { Todo } from "../src/domain/todo/todo.entity"; @@ -27,7 +27,7 @@ suite("TodoService Unit Tests", () => { todoService = new TodoService(mockTodoRepo as TodoRepository); }); - test("Insert", async () => { + it("Insert", async () => { const newTodo = await todoService.add("Hello World"); expect(newTodo.content).toBe("Hello World"); @@ -35,26 +35,26 @@ suite("TodoService Unit Tests", () => { expect(mockTodoRepo.insert).toHaveBeenCalledWith("Hello World"); }); - test("Select", async () => { + it("Select", async () => { const todo = await todoService.findById(1); expect(todo?.content).toBe("Hello World"); expect(mockTodoRepo.findById).toHaveBeenCalledWith(1); }); - test("Update", async () => { + it("Update", async () => { await todoService.complete(1); expect(mockTodoRepo.update).toHaveBeenCalledWith(1); }); - test("Delete", async () => { + it("Delete", async () => { await todoService.deleteById(1); expect(mockTodoRepo.delete).toHaveBeenCalledWith(1); }); - test("Find All", async () => { + it("Find All", async () => { const todoList = await todoService.findAll(); expect(todoList).toEqual([mockTodo]); diff --git a/examples/with-typeorm/packages/typeorm-service/__test__/typeorm.test.ts b/examples/with-typeorm/packages/typeorm-service/__test__/typeorm.test.ts index 28aaa562dfed6..3b63db193f9d3 100755 --- a/examples/with-typeorm/packages/typeorm-service/__test__/typeorm.test.ts +++ b/examples/with-typeorm/packages/typeorm-service/__test__/typeorm.test.ts @@ -1,4 +1,4 @@ -import { suite, test, beforeEach, expect } from "vitest"; +import { suite, it, beforeEach, expect } from "vitest"; import "reflect-metadata"; import { DataSource, @@ -44,7 +44,7 @@ suite("typeorm with SQL.js", () => { todoRepo = dataSource.getRepository(Todo); }); - test("Insert", async () => { + it("Insert", async () => { const newTodo = await todoRepo.save({ content: "Hello World", complete: false, @@ -53,7 +53,7 @@ suite("typeorm with SQL.js", () => { expect(newTodo.complete).toBeFalsy(); }); - test("Select", async () => { + it("Select", async () => { const newTodo = await todoRepo.save({ content: "Hello World", complete: false, @@ -63,7 +63,7 @@ suite("typeorm with SQL.js", () => { expect(todo?.content).toBe("Hello World"); }); - test("Update", async () => { + it("Update", async () => { const newTodo = await todoRepo.save({ content: "Hello World", complete: false, @@ -73,7 +73,7 @@ suite("typeorm with SQL.js", () => { expect(todo?.complete).toBeTruthy(); }); - test("Delete", async () => { + it("Delete", async () => { const newTodo = await todoRepo.save({ content: "Hello World", complete: false, diff --git a/packages/create-turbo/__tests__/git.test.ts b/packages/create-turbo/__tests__/git.test.ts index 4c6b239b8af75..a78698f60d0cf 100644 --- a/packages/create-turbo/__tests__/git.test.ts +++ b/packages/create-turbo/__tests__/git.test.ts @@ -1,4 +1,7 @@ -import path from "path"; +import path from "node:path"; +import childProcess from "node:child_process"; +import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { DEFAULT_IGNORE, GIT_REPO_COMMAND, @@ -7,8 +10,6 @@ import { isInMercurialRepository, tryGitInit, } from "../src/utils/git"; -import childProcess from "child_process"; -import { setupTestFixtures } from "@turbo/test-utils"; describe("git", () => { // just to make sure this doesn't get lost diff --git a/packages/create-turbo/__tests__/index.test.ts b/packages/create-turbo/__tests__/index.test.ts index eb54a78b2541c..262e953240ae1 100644 --- a/packages/create-turbo/__tests__/index.test.ts +++ b/packages/create-turbo/__tests__/index.test.ts @@ -8,11 +8,12 @@ import type { PackageManager } from "@turbo/utils"; import * as turboWorkspaces from "@turbo/workspaces"; import { CreateTurboTelemetry, TelemetryConfig } from "@turbo/telemetry"; import * as turboUtils from "@turbo/utils"; +import { describe, it, expect, jest } from "@jest/globals"; import type { CreateCommandArgument } from "../src/commands/create/types"; import { create } from "../src/commands/create"; import { getWorkspaceDetailsMockReturnValue } from "./test-utils"; -jest.mock("@turbo/workspaces", () => ({ +jest.mock("@turbo/workspaces", () => ({ __esModule: true, ...jest.requireActual("@turbo/workspaces"), })); @@ -41,7 +42,7 @@ describe("create-turbo", () => { }), }); - test.each<{ packageManager: PackageManager }>([ + it.each<{ packageManager: PackageManager }>([ { packageManager: "yarn" }, { packageManager: "npm" }, { packageManager: "pnpm" }, @@ -124,7 +125,7 @@ describe("create-turbo", () => { } ); - test.each<{ packageManager: PackageManager }>([ + it.each<{ packageManager: PackageManager }>([ { packageManager: "yarn" }, { packageManager: "npm" }, { packageManager: "pnpm" }, @@ -206,7 +207,7 @@ describe("create-turbo", () => { } ); - test("throws correct error message when a download error is encountered", async () => { + it("throws correct error message when a download error is encountered", async () => { const { root } = useFixture({ fixture: `create-turbo` }); const packageManager = "pnpm"; const mockAvailablePackageManagers = jest diff --git a/packages/create-turbo/package.json b/packages/create-turbo/package.json index 3b1a831f7bacd..77b1f22533753 100644 --- a/packages/create-turbo/package.json +++ b/packages/create-turbo/package.json @@ -32,6 +32,7 @@ "update-check": "^1.5.4" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/telemetry": "workspace:*", "@turbo/test-utils": "workspace:*", @@ -40,7 +41,6 @@ "@turbo/workspaces": "workspace:*", "@types/fs-extra": "^9.0.13", "@types/inquirer": "^7.3.1", - "@types/jest": "^29.5.13", "@types/node": "^18.17.2", "@types/semver": "^7.3.9", "jest": "^29.7.0", diff --git a/packages/eslint-plugin-turbo/__tests__/cwd.test.ts b/packages/eslint-plugin-turbo/__tests__/cwd.test.ts index 3901a1cbcd512..e7f32a3a15873 100644 --- a/packages/eslint-plugin-turbo/__tests__/cwd.test.ts +++ b/packages/eslint-plugin-turbo/__tests__/cwd.test.ts @@ -3,6 +3,7 @@ import { execSync } from "node:child_process"; import { type Schema } from "@turbo/types"; import { parse, stringify } from "json5"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; describe("eslint settings check", () => { const { useFixture } = setupTestFixtures({ diff --git a/packages/eslint-plugin-turbo/package.json b/packages/eslint-plugin-turbo/package.json index 7d8d2b750e10a..78cb0120863ca 100644 --- a/packages/eslint-plugin-turbo/package.json +++ b/packages/eslint-plugin-turbo/package.json @@ -35,6 +35,7 @@ "dotenv": "16.0.3" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/test-utils": "workspace:*", "@turbo/tsconfig": "workspace:*", @@ -42,7 +43,6 @@ "@turbo/utils": "workspace:*", "@types/eslint": "^8.4.5", "@types/estree": "^1.0.0", - "@types/jest": "^29.5.13", "@types/node": "^18.17.2", "jest": "^29.7.0", "json5": "^2.2.1", diff --git a/packages/turbo-benchmark/package.json b/packages/turbo-benchmark/package.json index 28e1c670d696e..4c0ffeed86515 100644 --- a/packages/turbo-benchmark/package.json +++ b/packages/turbo-benchmark/package.json @@ -34,6 +34,7 @@ "vega": "^5.27.0" }, "devDependencies": { + "@jest/globals": "29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/tsconfig": "workspace:*", "@types/fs-extra": "^9.0.13", diff --git a/packages/turbo-benchmark/src/templates/src/__tests__/index.test.ts b/packages/turbo-benchmark/src/templates/src/__tests__/index.test.ts index 9a4831a645b0a..6a91522a3409b 100644 --- a/packages/turbo-benchmark/src/templates/src/__tests__/index.test.ts +++ b/packages/turbo-benchmark/src/templates/src/__tests__/index.test.ts @@ -1,4 +1,5 @@ import { sum } from "../."; +import { describe, it, expect } from "@jest/globals"; describe("Hello", () => { it("renders without crashing", () => { diff --git a/packages/turbo-codemod/__tests__/add-package-manager.test.ts b/packages/turbo-codemod/__tests__/add-package-manager.test.ts index 4ac4edb354e72..374997e222e69 100644 --- a/packages/turbo-codemod/__tests__/add-package-manager.test.ts +++ b/packages/turbo-codemod/__tests__/add-package-manager.test.ts @@ -2,12 +2,13 @@ import fs from "fs-extra"; import * as turboWorkspaces from "@turbo/workspaces"; import * as turboUtils from "@turbo/utils"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { transformer } from "../src/transforms/add-package-manager"; import type { TransformerResults } from "../src/runner"; import type { TransformerOptions } from "../src/types"; import { getWorkspaceDetailsMockReturnValue } from "./test-utils"; -jest.mock("@turbo/workspaces", () => ({ +jest.mock("@turbo/workspaces", () => ({ __esModule: true, ...jest.requireActual("@turbo/workspaces"), })); @@ -121,7 +122,7 @@ describe("add-package-manager-2", () => { test: "add-package-manager", }); - test.each(TEST_CASES)( + it.each(TEST_CASES)( "$fixture - $name with $packageManager@$packageManagerVersion using $options", async ({ fixture, @@ -193,7 +194,7 @@ describe("add-package-manager-2", () => { ); describe("errors", () => { - test("unable to determine workspace manager", async () => { + it("unable to determine workspace manager", async () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-package-manager" }); @@ -221,7 +222,7 @@ describe("add-package-manager-2", () => { mockGetWorkspaceDetails.mockRestore(); }); - test("unable to determine package manager version", async () => { + it("unable to determine package manager version", async () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-package-manager" }); @@ -265,7 +266,7 @@ describe("add-package-manager-2", () => { mockGetWorkspaceDetails.mockRestore(); }); - test("unable to write json", async () => { + it("unable to write json", async () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-package-manager" }); diff --git a/packages/turbo-codemod/__tests__/add-package-names.test.ts b/packages/turbo-codemod/__tests__/add-package-names.test.ts index 4f842a2988d41..bf66f60b9978a 100644 --- a/packages/turbo-codemod/__tests__/add-package-names.test.ts +++ b/packages/turbo-codemod/__tests__/add-package-names.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/add-package-names"; describe("add-package-names", () => { @@ -7,7 +8,7 @@ describe("add-package-names", () => { test: "add-package-names", }); - test("missing names", async () => { + it("missing names", async () => { // load the fixture for the test const { root, readJson } = useFixture({ fixture: "missing-names", @@ -49,7 +50,7 @@ describe("add-package-names", () => { } }); - test("duplicate names", async () => { + it("duplicate names", async () => { // load the fixture for the test const { root, readJson } = useFixture({ fixture: "duplicate-names", @@ -86,7 +87,7 @@ describe("add-package-names", () => { } }); - test("correct names", async () => { + it("correct names", async () => { // load the fixture for the test const { root, readJson } = useFixture({ fixture: "correct-names", @@ -115,7 +116,7 @@ describe("add-package-names", () => { } }); - test("ignored packages", async () => { + it("ignored packages", async () => { // load the fixture for the test const { root, readJson } = useFixture({ fixture: "ignored-packages", diff --git a/packages/turbo-codemod/__tests__/clean-globs.test.ts b/packages/turbo-codemod/__tests__/clean-globs.test.ts index 02e649fe5b339..63a9622fb4a23 100644 --- a/packages/turbo-codemod/__tests__/clean-globs.test.ts +++ b/packages/turbo-codemod/__tests__/clean-globs.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer, fixGlobPattern } from "../src/transforms/clean-globs"; describe("clean-globs", () => { @@ -7,7 +8,7 @@ describe("clean-globs", () => { test: "clean-globs", }); - test("basic", () => { + it("basic", () => { // load the fixture for the test const { root } = useFixture({ fixture: "clean-globs", @@ -32,7 +33,7 @@ describe("clean-globs", () => { `); }); - test("collapses back-to-back doublestars", () => { + it("collapses back-to-back doublestars", () => { const badGlobPatterns = [ ["../../app-store/**/**", "../../app-store/**"], ["**/**/result.json", "**/result.json"], @@ -48,12 +49,12 @@ describe("clean-globs", () => { }); }); - test("doesn't update valid globs and prints a message", () => { + it("doesn't update valid globs and prints a message", () => { // Now let's test the function expect(fixGlobPattern("a/b/c/*")).toBe("a/b/c/*"); }); - test("transforms '**ext' to '**/*ext'", () => { + it("transforms '**ext' to '**/*ext'", () => { const badGlobPatterns = [ ["cypress/integration/**.test.ts", "cypress/integration/**/*.test.ts"], ["scripts/**.mjs", "scripts/**/*.mjs"], @@ -70,7 +71,7 @@ describe("clean-globs", () => { }); }); - test("transforms 'pre**' to pre*/**", () => { + it("transforms 'pre**' to pre*/**", () => { const badGlobPatterns = [ ["pre**", "pre*/**"], ["pre**/foo", "pre*/**/foo"], diff --git a/packages/turbo-codemod/__tests__/create-turbo-config.test.ts b/packages/turbo-codemod/__tests__/create-turbo-config.test.ts index 78178560092f8..d7bf60e04fe08 100644 --- a/packages/turbo-codemod/__tests__/create-turbo-config.test.ts +++ b/packages/turbo-codemod/__tests__/create-turbo-config.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import fs from "fs-extra"; import { transformer } from "../src/transforms/create-turbo-config"; @@ -8,7 +9,7 @@ describe("create-turbo-config", () => { test: "create-turbo-config", }); - test("package.json config exists but no turbo.json config - basic", () => { + it("package.json config exists but no turbo.json config - basic", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); @@ -45,7 +46,7 @@ describe("create-turbo-config", () => { `); }); - test("package.json config exists but no turbo.json config - repeat run", () => { + it("package.json config exists but no turbo.json config - repeat run", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); @@ -104,7 +105,7 @@ describe("create-turbo-config", () => { `); }); - test("package.json config exists but no turbo.json config - dry", () => { + it("package.json config exists but no turbo.json config - dry", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); @@ -141,7 +142,7 @@ describe("create-turbo-config", () => { `); }); - test("package.json config exists but no turbo.json config - print", () => { + it("package.json config exists but no turbo.json config - print", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); @@ -178,7 +179,7 @@ describe("create-turbo-config", () => { `); }); - test("package.json config exists but no turbo.json config - dry & print", () => { + it("package.json config exists but no turbo.json config - dry & print", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); @@ -215,7 +216,7 @@ describe("create-turbo-config", () => { `); }); - test("no package.json config or turbo.json file exists", () => { + it("no package.json config or turbo.json file exists", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-package-json-config" }); @@ -256,7 +257,7 @@ describe("create-turbo-config", () => { `); }); - test("no package.json file exists", () => { + it("no package.json file exists", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-package-json-file" }); @@ -278,7 +279,7 @@ describe("create-turbo-config", () => { ); }); - test("turbo.json file exists and no package.json config exists", () => { + it("turbo.json file exists and no package.json config exists", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "turbo-json-config" }); @@ -320,7 +321,7 @@ describe("create-turbo-config", () => { `); }); - test("turbo.json file exists and package.json config exists", () => { + it("turbo.json file exists and package.json config exists", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "both-configs" }); @@ -363,7 +364,7 @@ describe("create-turbo-config", () => { `); }); - test("errors when unable to write json", () => { + it("errors when unable to write json", () => { // load the fixture for the test const { root, read } = useFixture({ fixture: "no-turbo-json-config" }); diff --git a/packages/turbo-codemod/__tests__/generate-package-name.test.ts b/packages/turbo-codemod/__tests__/generate-package-name.test.ts index 9a4e210471113..a42d120191181 100644 --- a/packages/turbo-codemod/__tests__/generate-package-name.test.ts +++ b/packages/turbo-codemod/__tests__/generate-package-name.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect } from "@jest/globals"; import { getNewPkgName } from "../src/transforms/add-package-names"; describe("getNewPkgName", () => { diff --git a/packages/turbo-codemod/__tests__/get-transforms-for-migration.test.ts b/packages/turbo-codemod/__tests__/get-transforms-for-migration.test.ts index f30cd9ea08cc6..e1ddf72ecaa38 100644 --- a/packages/turbo-codemod/__tests__/get-transforms-for-migration.test.ts +++ b/packages/turbo-codemod/__tests__/get-transforms-for-migration.test.ts @@ -1,7 +1,8 @@ +import { describe, it, expect } from "@jest/globals"; import { getTransformsForMigration } from "../src/commands/migrate/steps/getTransformsForMigration"; describe("get-transforms-for-migration", () => { - test("ordering", () => { + it("ordering", () => { const results = getTransformsForMigration({ fromVersion: "1.0.0", toVersion: "1.10.0", diff --git a/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts b/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts index 8bbee953f8c59..ac8b97dd4287c 100644 --- a/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts +++ b/packages/turbo-codemod/__tests__/get-turbo-upgrade-command.test.ts @@ -1,11 +1,12 @@ import * as turboWorkspaces from "@turbo/workspaces"; import * as turboUtils from "@turbo/utils"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { getTurboUpgradeCommand } from "../src/commands/migrate/steps/getTurboUpgradeCommand"; import * as utils from "../src/commands/migrate/utils"; import { getWorkspaceDetailsMockReturnValue } from "./test-utils"; -jest.mock("@turbo/workspaces", () => ({ +jest.mock("@turbo/workspaces", () => ({ __esModule: true, ...jest.requireActual("@turbo/workspaces"), })); @@ -430,7 +431,7 @@ describe("get-turbo-upgrade-command", () => { test: "get-turbo-upgrade-command", }); - test.each(LOCAL_INSTALL_COMMANDS)( + it.each(LOCAL_INSTALL_COMMANDS)( "returns correct upgrade command for local install of turbo@$version using $packageManager@$packageManagerVersion (fixture: $fixture)", async ({ version, @@ -492,7 +493,7 @@ describe("get-turbo-upgrade-command", () => { } ); - test.each(GLOBAL_INSTALL_COMMANDS)( + it.each(GLOBAL_INSTALL_COMMANDS)( "returns correct upgrade command for global install of turbo@$version using $packageManager@$packageManagerVersion (fixture: $fixture)", async ({ version, @@ -555,7 +556,7 @@ describe("get-turbo-upgrade-command", () => { ); describe("errors", () => { - test("fails gracefully if no package.json exists", async () => { + it("fails gracefully if no package.json exists", async () => { const { root } = useFixture({ fixture: "no-package", }); @@ -598,7 +599,7 @@ describe("get-turbo-upgrade-command", () => { mockGetWorkspaceDetails.mockRestore(); }); - test.each([ + it.each([ { fixture: "no-package", name: "fails gracefully if no package.json exists", diff --git a/packages/turbo-codemod/__tests__/migrate-dot-env.test.ts b/packages/turbo-codemod/__tests__/migrate-dot-env.test.ts index 878b0d61aa9ce..9f4ec2c8a7843 100644 --- a/packages/turbo-codemod/__tests__/migrate-dot-env.test.ts +++ b/packages/turbo-codemod/__tests__/migrate-dot-env.test.ts @@ -1,5 +1,6 @@ import { setupTestFixtures } from "@turbo/test-utils"; import { type Schema } from "@turbo/types"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/migrate-dot-env"; describe("migrate-dot-env", () => { diff --git a/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts b/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts index 473d3f0b4a9da..d15031ef7b300 100644 --- a/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts +++ b/packages/turbo-codemod/__tests__/migrate-env-var-dependencies.test.ts @@ -1,6 +1,7 @@ import merge from "deepmerge"; import type { SchemaV1, SchemaV2 } from "@turbo/types"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { hasLegacyEnvVarDependencies, migratePipeline, diff --git a/packages/turbo-codemod/__tests__/migrate.test.ts b/packages/turbo-codemod/__tests__/migrate.test.ts index 021b5016fb8da..23b7acdd88c51 100644 --- a/packages/turbo-codemod/__tests__/migrate.test.ts +++ b/packages/turbo-codemod/__tests__/migrate.test.ts @@ -2,6 +2,7 @@ import childProcess from "node:child_process"; import * as turboUtils from "@turbo/utils"; import * as turboWorkspaces from "@turbo/workspaces"; import { setupTestFixtures, spyExit } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { migrate } from "../src/commands/migrate"; import * as checkGitStatus from "../src/utils/checkGitStatus"; import * as getCurrentVersion from "../src/commands/migrate/steps/getCurrentVersion"; @@ -9,7 +10,7 @@ import * as getLatestVersion from "../src/commands/migrate/steps/getLatestVersio import * as getTurboUpgradeCommand from "../src/commands/migrate/steps/getTurboUpgradeCommand"; import { getWorkspaceDetailsMockReturnValue } from "./test-utils"; -jest.mock("@turbo/workspaces", () => ({ +jest.mock("@turbo/workspaces", () => ({ __esModule: true, ...jest.requireActual("@turbo/workspaces"), })); diff --git a/packages/turbo-codemod/__tests__/rename-output-mode.test.ts b/packages/turbo-codemod/__tests__/rename-output-mode.test.ts index 0e9f6c7064aab..d54a597b495da 100644 --- a/packages/turbo-codemod/__tests__/rename-output-mode.test.ts +++ b/packages/turbo-codemod/__tests__/rename-output-mode.test.ts @@ -1,5 +1,6 @@ import { setupTestFixtures } from "@turbo/test-utils"; import { type Schema } from "@turbo/types"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/rename-output-mode"; describe("rename-output-mode", () => { diff --git a/packages/turbo-codemod/__tests__/rename-pipeline.ts b/packages/turbo-codemod/__tests__/rename-pipeline.ts index f7cf3f909d5db..38c197bcf5ff1 100644 --- a/packages/turbo-codemod/__tests__/rename-pipeline.ts +++ b/packages/turbo-codemod/__tests__/rename-pipeline.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/rename-pipeline"; describe("rename-pipeline", () => { diff --git a/packages/turbo-codemod/__tests__/set-default-outputs.test.ts b/packages/turbo-codemod/__tests__/set-default-outputs.test.ts index 707059eff45e6..60460ec21ea1a 100644 --- a/packages/turbo-codemod/__tests__/set-default-outputs.test.ts +++ b/packages/turbo-codemod/__tests__/set-default-outputs.test.ts @@ -1,5 +1,6 @@ import { setupTestFixtures } from "@turbo/test-utils"; import { type Schema } from "@turbo/types"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/set-default-outputs"; describe("set-default-outputs", () => { diff --git a/packages/turbo-codemod/__tests__/stabilize-env-mode.test.ts b/packages/turbo-codemod/__tests__/stabilize-env-mode.test.ts index dcae6af493313..d60af37412524 100644 --- a/packages/turbo-codemod/__tests__/stabilize-env-mode.test.ts +++ b/packages/turbo-codemod/__tests__/stabilize-env-mode.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/stabilize-env-mode"; describe("stabilize-env-mode", () => { diff --git a/packages/turbo-codemod/__tests__/stabilize-ui.test.ts b/packages/turbo-codemod/__tests__/stabilize-ui.test.ts index 60364f7523b9e..4973b3cf8813b 100644 --- a/packages/turbo-codemod/__tests__/stabilize-ui.test.ts +++ b/packages/turbo-codemod/__tests__/stabilize-ui.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/stabilize-ui"; describe("stabilize-ui", () => { diff --git a/packages/turbo-codemod/__tests__/transform-env-literals-to-wildcards.test.ts b/packages/turbo-codemod/__tests__/transform-env-literals-to-wildcards.test.ts index 11c24a9050399..8e2e2b03b3dda 100644 --- a/packages/turbo-codemod/__tests__/transform-env-literals-to-wildcards.test.ts +++ b/packages/turbo-codemod/__tests__/transform-env-literals-to-wildcards.test.ts @@ -1,4 +1,5 @@ import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { transformer } from "../src/transforms/transform-env-literals-to-wildcards"; describe.only("transform-env-literals-to-wildcards", () => { diff --git a/packages/turbo-codemod/__tests__/transform.test.ts b/packages/turbo-codemod/__tests__/transform.test.ts index 84e68fb007f0e..3c2c7d8097d51 100644 --- a/packages/turbo-codemod/__tests__/transform.test.ts +++ b/packages/turbo-codemod/__tests__/transform.test.ts @@ -1,12 +1,13 @@ import * as turboWorkspaces from "@turbo/workspaces"; import * as turboUtils from "@turbo/utils"; import { setupTestFixtures, spyExit } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { transform } from "../src/commands/transform"; import * as checkGitStatus from "../src/utils/checkGitStatus"; import type { MigrateCommandArgument } from "../src/commands"; import { getWorkspaceDetailsMockReturnValue } from "./test-utils"; -jest.mock("@turbo/workspaces", () => ({ +jest.mock("@turbo/workspaces", () => ({ __esModule: true, ...jest.requireActual("@turbo/workspaces"), })); diff --git a/packages/turbo-codemod/package.json b/packages/turbo-codemod/package.json index 7abffcf858d33..b1c96aeeffa6c 100644 --- a/packages/turbo-codemod/package.json +++ b/packages/turbo-codemod/package.json @@ -38,6 +38,7 @@ "update-check": "^1.5.4" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/gen": "workspace:*", "@turbo/test-utils": "workspace:*", @@ -49,7 +50,6 @@ "@types/fs-extra": "^9.0.13", "@types/gradient-string": "^1.1.2", "@types/inquirer": "^8.2.0", - "@types/jest": "^29.5.13", "@types/node": "^18.17.2", "@types/semver": "^7.3.9", "@types/uuid": "^9.0.0", diff --git a/packages/turbo-codemod/turbo/generators/templates/transformer.test.hbs b/packages/turbo-codemod/turbo/generators/templates/transformer.test.hbs index c63a9df4bf4ca..80df9d4d368eb 100644 --- a/packages/turbo-codemod/turbo/generators/templates/transformer.test.hbs +++ b/packages/turbo-codemod/turbo/generators/templates/transformer.test.hbs @@ -1,11 +1,12 @@ +import { describe, it, expect } from '@jest/globals'; import { transformer } from "../src/transforms/{{ name }}"; import { setupTestFixtures } from "./test-utils"; describe("{{ name }}", () => { - + const { useFixture } = setupTestFixtures({ test: "{{ name }}" }); - test("basic", () => { + it("basic", () => { // load the fixture for the test const { root, read, readJson } = useFixture({ fixture: "specific-fixture", diff --git a/packages/turbo-gen/__tests__/raw.test.ts b/packages/turbo-gen/__tests__/raw.test.ts index 48169ddcba541..127a03d15bace 100644 --- a/packages/turbo-gen/__tests__/raw.test.ts +++ b/packages/turbo-gen/__tests__/raw.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect, jest } from "@jest/globals"; import { raw } from "../src/commands/raw"; import * as run from "../src/commands/run"; import * as workspace from "../src/commands/workspace"; @@ -135,7 +136,7 @@ describe("raw", () => { }, }, ]; - test.each(testMatrix)( + it.each(testMatrix)( "$command and $options calls $target with $calledWith", async ({ command, options, target, calledWith }) => { // mock generation functions, we only care if they are called, diff --git a/packages/turbo-gen/package.json b/packages/turbo-gen/package.json index 360f7dd50448c..d61ef8a87f868 100644 --- a/packages/turbo-gen/package.json +++ b/packages/turbo-gen/package.json @@ -34,13 +34,13 @@ "validate-npm-package-name": "^5.0.0" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/test-utils": "workspace:*", "@turbo/tsconfig": "workspace:*", "@turbo/utils": "workspace:*", "@types/fs-extra": "^9.0.13", "@types/inquirer": "^8.2.5", - "@types/jest": "^29.5.13", "@types/node": "^18.17.2", "@types/validate-npm-package-name": "^4.0.0", "jest": "^29.7.0", diff --git a/packages/turbo-ignore/__tests__/checkCommit.test.ts b/packages/turbo-ignore/__tests__/checkCommit.test.ts index a5a94da80d112..f5e8881e75077 100644 --- a/packages/turbo-ignore/__tests__/checkCommit.test.ts +++ b/packages/turbo-ignore/__tests__/checkCommit.test.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line camelcase -- this is a good exception to this rule import child_process from "node:child_process"; import { mockEnv } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { checkCommit } from "../src/checkCommit"; describe("checkCommit()", () => { diff --git a/packages/turbo-ignore/__tests__/errors.test.ts b/packages/turbo-ignore/__tests__/errors.test.ts index 02e40b52cd97b..da8e3b47ec329 100644 --- a/packages/turbo-ignore/__tests__/errors.test.ts +++ b/packages/turbo-ignore/__tests__/errors.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect } from "@jest/globals"; import { shouldWarn, NON_FATAL_ERRORS } from "../src/errors"; describe("shouldWarn()", () => { diff --git a/packages/turbo-ignore/__tests__/getComparison.test.ts b/packages/turbo-ignore/__tests__/getComparison.test.ts index e5b7b7f82bcb4..7a194353e364f 100644 --- a/packages/turbo-ignore/__tests__/getComparison.test.ts +++ b/packages/turbo-ignore/__tests__/getComparison.test.ts @@ -1,6 +1,7 @@ // eslint-disable-next-line camelcase -- This is a test file import child_process from "node:child_process"; import { spyConsole, mockEnv, validateLogs } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { getComparison } from "../src/getComparison"; describe("getComparison()", () => { @@ -25,21 +26,22 @@ describe("getComparison()", () => { "type": "customFallback", } `); - validateLogs(["Falling back to ref HEAD^2"], mockConsole.log, { - prefix: "≫ ", - }); + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + "Falling back to ref HEAD^2" + ); }); it("returns null when running in Vercel CI with no VERCEL_GIT_PREVIOUS_SHA", () => { process.env.VERCEL = "1"; process.env.VERCEL_GIT_COMMIT_REF = "my-branch"; expect(getComparison({ workspace: "test-workspace" })).toBeNull(); - validateLogs( - [ - 'No previous deployments found for "test-workspace" on branch "my-branch"', - ], - mockConsole.log, - { prefix: "≫ " } + + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'No previous deployments found for "test-workspace" on branch "my-branch"' ); }); @@ -54,14 +56,13 @@ describe("getComparison()", () => { } `); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", 'No previous deployments found for "test-workspace" on branch "my-branch"', - "Falling back to ref HEAD^2", ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", "Falling back to ref HEAD^2"], + ]); }); it("modifies output when running in Vercel CI with no VERCEL_GIT_PREVIOUS_SHA and no VERCEL_GIT_COMMIT_REF", () => { @@ -74,14 +75,10 @@ describe("getComparison()", () => { } `); - validateLogs( - [ - 'No previous deployments found for "test-workspace"', - "Falling back to ref HEAD^2", - ], - mockConsole.log, - { prefix: "≫ " } - ); + validateLogs(mockConsole.log, [ + ["≫ ", 'No previous deployments found for "test-workspace"'], + ["≫ ", "Falling back to ref HEAD^2"], + ]); }); it("uses previousDeploy when running in Vercel CI with VERCEL_GIT_PREVIOUS_SHA", () => { @@ -100,12 +97,10 @@ describe("getComparison()", () => { } `); - validateLogs( - [ - 'Found previous deployment ("mygitsha") for "test-workspace" on branch "my-branch"', - ], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Found previous deployment ("mygitsha") for "test-workspace" on branch "my-branch"' ); mockExec.mockRestore(); @@ -129,14 +124,13 @@ describe("getComparison()", () => { } `); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", 'Previous deployment ("mygitsha") for "test-workspace" on branch "my-branch" is unreachable.', - "Falling back to ref HEAD^2", ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", "Falling back to ref HEAD^2"], + ]); mockExec.mockRestore(); }); @@ -153,12 +147,10 @@ describe("getComparison()", () => { process.env.VERCEL_GIT_COMMIT_REF = "my-branch"; expect(getComparison({ workspace: "test-workspace" })).toBeNull(); - validateLogs( - [ - 'Previous deployment ("mygitsha") for "test-workspace" on branch "my-branch" is unreachable.', - ], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Previous deployment ("mygitsha") for "test-workspace" on branch "my-branch" is unreachable.' ); mockExec.mockRestore(); @@ -179,10 +171,10 @@ describe("getComparison()", () => { } `); - validateLogs( - ['Found previous deployment ("mygitsha") for "test-workspace"'], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Found previous deployment ("mygitsha") for "test-workspace"' ); mockExec.mockRestore(); @@ -199,10 +191,10 @@ describe("getComparison()", () => { process.env.VERCEL_GIT_PREVIOUS_SHA = "mygitsha"; expect(getComparison({ workspace: "test-workspace" })).toBeNull(); - validateLogs( - ['Previous deployment ("mygitsha") for "test-workspace" is unreachable.'], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Previous deployment ("mygitsha") for "test-workspace" is unreachable.' ); mockExec.mockRestore(); diff --git a/packages/turbo-ignore/__tests__/getTask.test.ts b/packages/turbo-ignore/__tests__/getTask.test.ts index e5040b41c089c..7c23eb3b16576 100644 --- a/packages/turbo-ignore/__tests__/getTask.test.ts +++ b/packages/turbo-ignore/__tests__/getTask.test.ts @@ -1,14 +1,15 @@ -import { spyConsole, validateLogs } from "@turbo/test-utils"; +import { spyConsole } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { getTask } from "../src/getTask"; describe("getWorkspace()", () => { const mockConsole = spyConsole(); it("getTask defaults to build", () => { expect(getTask({})).toEqual("build"); - validateLogs( - ['Using "build" as the task as it was unspecified'], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Using "build" as the task as it was unspecified' ); }); @@ -18,10 +19,11 @@ describe("getWorkspace()", () => { task: "workspace#task", }) ).toEqual(`"workspace#task"`); - validateLogs( - ['Using "workspace#task" as the task from the arguments'], - mockConsole.log, - { prefix: "≫ " } + + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Using "workspace#task" as the task from the arguments' ); }); }); diff --git a/packages/turbo-ignore/__tests__/getTurboVersion.test.ts b/packages/turbo-ignore/__tests__/getTurboVersion.test.ts index 5852abd19114e..0e41c42fd7fd5 100644 --- a/packages/turbo-ignore/__tests__/getTurboVersion.test.ts +++ b/packages/turbo-ignore/__tests__/getTurboVersion.test.ts @@ -1,4 +1,5 @@ -import { spyConsole, validateLogs } from "@turbo/test-utils"; +import { spyConsole } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { getTurboVersion } from "../src/getTurboVersion"; describe("getWorkspace()", () => { @@ -12,10 +13,11 @@ describe("getWorkspace()", () => { "./__fixtures__/app" ) ).toEqual("1.2.3"); - validateLogs( - ['Using turbo version "1.2.3" from arguments'], - mockConsole.log, - { prefix: "≫ " } + + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Using turbo version "1.2.3" from arguments' ); }); diff --git a/packages/turbo-ignore/__tests__/getWorkspace.test.ts b/packages/turbo-ignore/__tests__/getWorkspace.test.ts index 7384ce8efd79f..42a4f693a6722 100644 --- a/packages/turbo-ignore/__tests__/getWorkspace.test.ts +++ b/packages/turbo-ignore/__tests__/getWorkspace.test.ts @@ -1,4 +1,5 @@ -import { spyConsole, validateLogs } from "@turbo/test-utils"; +import { spyConsole } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { getWorkspace } from "../src/getWorkspace"; describe("getWorkspace()", () => { @@ -9,10 +10,10 @@ describe("getWorkspace()", () => { workspace: "test-workspace", }) ).toEqual("test-workspace"); - validateLogs( - ['Using "test-workspace" as workspace from arguments'], - mockConsole.log, - { prefix: "≫ " } + expect(mockConsole.log).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Using "test-workspace" as workspace from arguments' ); }); diff --git a/packages/turbo-ignore/__tests__/ignore.test.ts b/packages/turbo-ignore/__tests__/ignore.test.ts index a21268d3ea613..b5fe5f42a9b1b 100644 --- a/packages/turbo-ignore/__tests__/ignore.test.ts +++ b/packages/turbo-ignore/__tests__/ignore.test.ts @@ -10,6 +10,7 @@ import { mockEnv, validateLogs, } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { TurboIgnoreTelemetry, TelemetryConfig } from "@turbo/telemetry"; import { turboIgnore } from "../src/ignore"; @@ -64,9 +65,11 @@ describe("turboIgnore()", () => { expect.anything() ); - validateLogs(["UNKNOWN_ERROR: error details"], mockConsole.error, { - prefix: "≫ ", - }); + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, + "≫ ", + "UNKNOWN_ERROR: error details" + ); expectBuild(mockExit); mockExec.mockRestore(); @@ -97,12 +100,10 @@ describe("turboIgnore()", () => { expect.anything() ); - validateLogs( - [ - `turbo-ignore could not complete - no package manager detected, please commit a lockfile, or set "packageManager" in your root "package.json"`, - ], - mockConsole.warn, - { prefix: "≫ " } + expect(mockConsole.warn).toHaveBeenNthCalledWith( + 1, + "≫ ", + `turbo-ignore could not complete - no package manager detected, please commit a lockfile, or set "packageManager" in your root "package.json"` ); expectBuild(mockExit); @@ -142,12 +143,10 @@ describe("turboIgnore()", () => { expect.anything() ); - validateLogs( - [ - `turbo-ignore could not complete - a ref or SHA is invalid. It could have been removed from the branch history via a force push, or this could be a shallow clone with insufficient history`, - ], - mockConsole.warn, - { prefix: "≫ " } + expect(mockConsole.warn).toHaveBeenNthCalledWith( + 1, + "≫ ", + `turbo-ignore could not complete - a ref or SHA is invalid. It could have been removed from the branch history via a force push, or this could be a shallow clone with insufficient history` ); expectBuild(mockExit); @@ -180,12 +179,10 @@ describe("turboIgnore()", () => { expect.anything() ); - validateLogs( - [ - `turbo-ignore could not complete - parent commit does not exist or is unreachable`, - ], - mockConsole.warn, - { prefix: "≫ " } + expect(mockConsole.warn).toHaveBeenNthCalledWith( + 1, + "≫ ", + `turbo-ignore could not complete - parent commit does not exist or is unreachable` ); expectBuild(mockExit); @@ -194,32 +191,23 @@ describe("turboIgnore()", () => { it("skips checks and allows build when no workspace can be found", () => { turboIgnore(undefined, { directory: "__fixtures__/no-app" }); - validateLogs( - [ - () => [ - "≫ ", - expect.stringContaining( - " could not be found. turbo-ignore inferencing failed" - ), - ], - ], - mockConsole.error, - { prefix: "≫ " } + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, + "≫ ", + expect.stringContaining( + " could not be found. turbo-ignore inferencing failed" + ) ); + expectBuild(mockExit); }); it("skips checks and allows build when a workspace with no name is found", () => { turboIgnore(undefined, { directory: "__fixtures__/invalid-app" }); - validateLogs( - [ - () => [ - "≫ ", - expect.stringContaining(' is missing the "name" field (required).'), - ], - ], - mockConsole.error, - { prefix: "≫ " } + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, + "≫ ", + expect.stringContaining(' is missing the "name" field (required).') ); expectBuild(mockExit); }); @@ -227,7 +215,8 @@ describe("turboIgnore()", () => { it("skips checks and allows build when no monorepo root can be found", () => { turboIgnore(undefined, { directory: "/" }); expectBuild(mockExit); - expect(mockConsole.error).toHaveBeenLastCalledWith( + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, "≫ ", "Monorepo root not found. turbo-ignore inferencing failed" ); @@ -279,20 +268,25 @@ describe("turboIgnore()", () => { return {} as unknown as ChildProcess; }); turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + [ + "≫ ", `Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"`, + ], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', - "This project and its dependencies are not affected", - () => expect.stringContaining("⏭ Ignoring the change"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", "This project and its dependencies are not affected"], + [expect.stringContaining("⏭ Ignoring the change")], + ]); expectIgnore(mockExit); mockExecSync.mockRestore(); @@ -324,20 +318,25 @@ describe("turboIgnore()", () => { task: "workspace#build", directory: "__fixtures__/app", }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "workspace#build" as the task from the arguments', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "workspace#build" as the task from the arguments'], + [ + "≫ ", 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', + ], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run "workspace#build" --filter="test-app...[last-deployed-sha]" --dry=json`', - 'This commit affects "test-app"', - () => expect.stringContaining("✓ Proceeding with deployment"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", 'This commit affects "test-app"'], + [expect.stringContaining("✓ Proceeding with deployment")], + ]); expectBuild(mockExit); mockExecSync.mockRestore(); @@ -366,20 +365,25 @@ describe("turboIgnore()", () => { return {} as unknown as ChildProcess; }); turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + [ + "≫ ", 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', + ], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', - 'This commit affects "test-app" and 1 dependency (ui)', - () => expect.stringContaining("✓ Proceeding with deployment"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", 'This commit affects "test-app" and 1 dependency (ui)'], + [expect.stringContaining("✓ Proceeding with deployment")], + ]); expectBuild(mockExit); mockExecSync.mockRestore(); @@ -408,20 +412,28 @@ describe("turboIgnore()", () => { return {} as unknown as ChildProcess; }); turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + [ + "≫ ", 'Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"', + ], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', + ], + [ + "≫ ", 'This commit affects "test-app" and 2 dependencies (ui, tsconfig)', - () => expect.stringContaining("✓ Proceeding with deployment"), ], - mockConsole.log, - { prefix: "≫ " } - ); + [expect.stringContaining("✓ Proceeding with deployment")], + ]); expectBuild(mockExit); mockExecSync.mockRestore(); @@ -459,21 +471,26 @@ describe("turboIgnore()", () => { fallback: "HEAD^2", directory: "__fixtures__/app", }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "workspace#build" as the task from the arguments', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "workspace#build" as the task from the arguments'], + [ + "≫ ", 'Previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch" is unreachable.', - "Falling back to ref HEAD^2", + ], + ["≫ ", "Falling back to ref HEAD^2"], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run "workspace#build" --filter="test-app...[HEAD^2]" --dry=json`', - 'This commit affects "test-app"', - () => expect.stringContaining("✓ Proceeding with deployment"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", 'This commit affects "test-app"'], + [expect.stringContaining("✓ Proceeding with deployment")], + ]); expectBuild(mockExit); mockExecSync.mockRestore(); @@ -497,12 +514,11 @@ describe("turboIgnore()", () => { expect.anything(), expect.anything() ); - validateLogs( - [ - 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.', - ], - mockConsole.error, - { prefix: "≫ " } + + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.' ); expectBuild(mockExit); @@ -530,12 +546,11 @@ describe("turboIgnore()", () => { expect.anything(), expect.anything() ); - validateLogs( - [ - 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.', - ], - mockConsole.error, - { prefix: "≫ " } + + expect(mockConsole.error).toHaveBeenNthCalledWith( + 1, + "≫ ", + 'Failed to parse JSON output from `npx -y turbo@^2 run build --filter="test-app...[HEAD^]" --dry=json`.' ); expectBuild(mockExit); @@ -548,18 +563,17 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', - "Found commit message: [vercel skip]", - () => expect.stringContaining("⏭ Ignoring the change"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + ["≫ ", "Found commit message: [vercel skip]"], + [expect.stringContaining("⏭ Ignoring the change")], + ]); expectIgnore(mockExit); }); @@ -570,18 +584,17 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', - "Found commit message: [vercel deploy]", - () => expect.stringContaining("✓ Proceeding with deployment"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + ["≫ ", "Found commit message: [vercel deploy]"], + [expect.stringContaining("✓ Proceeding with deployment")], + ]); expectBuild(mockExit); }); @@ -611,21 +624,29 @@ describe("turboIgnore()", () => { turboIgnore(undefined, { directory: "__fixtures__/app" }); - validateLogs( + validateLogs(mockConsole.log, [ [ + "≫ ", "Using Turborepo to determine if this project is affected by the commit...\n", - 'Inferred "test-app" as workspace from "package.json"', - 'Inferred turbo version ^2 based on "tasks" in "turbo.json"', - 'Using "build" as the task as it was unspecified', + ], + ["≫ ", 'Inferred "test-app" as workspace from "package.json"'], + ["≫ ", 'Inferred turbo version ^2 based on "tasks" in "turbo.json"'], + ["≫ ", 'Using "build" as the task as it was unspecified'], + [ + "≫ ", "Conflicting commit messages found: [vercel deploy] and [vercel skip]", + ], + [ + "≫ ", `Found previous deployment ("last-deployed-sha") for "test-app" on branch "my-branch"`, + ], + [ + "≫ ", 'Analyzing results of `npx -y turbo@^2 run build --filter="test-app...[last-deployed-sha]" --dry=json`', - "This project and its dependencies are not affected", - () => expect.stringContaining("⏭ Ignoring the change"), ], - mockConsole.log, - { prefix: "≫ " } - ); + ["≫ ", "This project and its dependencies are not affected"], + [expect.stringContaining("Ignoring the change")], + ]); expectIgnore(mockExit); mockExecSync.mockRestore(); diff --git a/packages/turbo-ignore/package.json b/packages/turbo-ignore/package.json index da2972725fb3e..1c3db20a114b1 100644 --- a/packages/turbo-ignore/package.json +++ b/packages/turbo-ignore/package.json @@ -29,13 +29,13 @@ "json5": "^2.2.3" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/telemetry": "workspace:*", "@turbo/test-utils": "workspace:*", "@turbo/tsconfig": "workspace:*", "@turbo/types": "workspace:*", "@turbo/utils": "workspace:*", - "@types/jest": "^29.5.13", "@types/node": "^18.17.2", "commander": "^11.0.0", "jest": "^29.7.0", diff --git a/packages/turbo-repository/__tests__/affected-packages.test.ts b/packages/turbo-repository/__tests__/affected-packages.test.ts index b91115a37ada9..9885078fd6ecb 100644 --- a/packages/turbo-repository/__tests__/affected-packages.test.ts +++ b/packages/turbo-repository/__tests__/affected-packages.test.ts @@ -1,4 +1,4 @@ -import { describe, test } from "node:test"; +import { describe, it } from "node:test"; import { strict as assert } from "node:assert"; import * as path from "node:path"; import { Workspace, Package, PackageManager } from "../js/dist/index.js"; @@ -43,7 +43,7 @@ describe("affectedPackages", () => { ]; for (const { description, files, expected } of tests) { - test(description, async () => { + it(description, async () => { const dir = path.resolve(__dirname, "./fixtures/monorepo"); const workspace = await Workspace.find(dir); diff --git a/packages/turbo-telemetry/src/config.test.ts b/packages/turbo-telemetry/src/config.test.ts index 2410ff83e758f..e1ad778cb1afa 100644 --- a/packages/turbo-telemetry/src/config.test.ts +++ b/packages/turbo-telemetry/src/config.test.ts @@ -1,4 +1,4 @@ -import { describe, test, mock, afterEach, beforeEach } from "node:test"; +import { describe, it, mock, afterEach, beforeEach } from "node:test"; import { strict as assert } from "node:assert"; import fs from "node:fs"; import { TelemetryConfig } from "./config"; @@ -28,7 +28,7 @@ describe("TelemetryConfig", () => { }); describe("fromDefaultConfig", () => { - test("should create TelemetryConfig instance from default config", async (t) => { + it("should create TelemetryConfig instance from default config", async (t) => { const mockConfigPath = "/path/to/defaultConfig.json"; const mockFileContent = JSON.stringify({ telemetry_enabled: true, @@ -53,7 +53,7 @@ describe("TelemetryConfig", () => { assert.equal(result?.id, "654321"); }); - test("should generate new config if default config doesn't exist", async (t) => { + it("should generate new config if default config doesn't exist", async (t) => { const mockConfigPath = "/path/to/defaultConfig.json"; const mockDefaultConfigPath = mock.fn(() => mockConfigPath); const mockReadFileSync = mock.fn(() => { @@ -102,7 +102,7 @@ describe("TelemetryConfig", () => { assert.equal(result?.config.telemetry_enabled, true); }); - test("should not throw if default config is missing a key", async (t) => { + it("should not throw if default config is missing a key", async (t) => { const mockConfigPath = "/path/to/defaultConfig.json"; const id = "654321"; const mockFileContent = JSON.stringify({ @@ -152,7 +152,7 @@ describe("TelemetryConfig", () => { assert.equal(result?.config.telemetry_enabled, true); }); - test("should not throw if default config has a key of the wrong type", async (t) => { + it("should not throw if default config has a key of the wrong type", async (t) => { const mockConfigPath = "/path/to/defaultConfig.json"; const salt = "default-salt"; const mockFileContent = JSON.stringify({ @@ -204,7 +204,7 @@ describe("TelemetryConfig", () => { }); describe("write", () => { - test("should write the config to the file", (t) => { + it("should write the config to the file", (t) => { const mockWriteFileSync = mock.fn(); t.mock.method(fs, "writeFileSync", mockWriteFileSync); @@ -217,7 +217,7 @@ describe("TelemetryConfig", () => { ]); }); - test("should not throw if write fails", (t) => { + it("should not throw if write fails", (t) => { const mockWriteFileSync = t.mock.method(fs, "writeFileSync", () => { throw new Error("Write error"); }); @@ -233,7 +233,7 @@ describe("TelemetryConfig", () => { }); describe("hasSeenAlert", () => { - test("should return true if telemetry_alerted is defined", () => { + it("should return true if telemetry_alerted is defined", () => { telemetryConfig = new TelemetryConfig({ configPath: "/path/to/config.json", config: { @@ -249,7 +249,7 @@ describe("TelemetryConfig", () => { assert.equal(result, true); }); - test("should return false if telemetry_alerted key exists but is undefined", () => { + it("should return false if telemetry_alerted key exists but is undefined", () => { telemetryConfig = new TelemetryConfig({ configPath: "/path/to/config.json", config: { @@ -264,7 +264,7 @@ describe("TelemetryConfig", () => { assert.equal(result, false); }); - test("should return false if telemetry_alerted is undefined", () => { + it("should return false if telemetry_alerted is undefined", () => { const result = telemetryConfig.hasSeenAlert(); assert.equal(result, false); @@ -284,7 +284,7 @@ describe("TelemetryConfig", () => { { envVar: null, value: null, expectedResult: true }, ]; for (const { envVar, value, expectedResult } of testCases) { - test(`should return ${expectedResult} when ${envVar} is set to '${value}'`, () => { + it(`should return ${expectedResult} when ${envVar} is set to '${value}'`, () => { const config = new TelemetryConfig({ configPath: "/path/to/config.json", config: { @@ -305,7 +305,7 @@ describe("TelemetryConfig", () => { }); describe("isTelemetryWarningEnabled", () => { - test("should return false if TURBO_TELEMETRY_MESSAGE_DISABLED is set to '1'", () => { + it("should return false if TURBO_TELEMETRY_MESSAGE_DISABLED is set to '1'", () => { process.env.TURBO_TELEMETRY_MESSAGE_DISABLED = "1"; const result = telemetryConfig.isTelemetryWarningEnabled(); @@ -313,7 +313,7 @@ describe("TelemetryConfig", () => { assert.equal(result, false); }); - test("should return false if TURBO_TELEMETRY_MESSAGE_DISABLED is set to 'true'", () => { + it("should return false if TURBO_TELEMETRY_MESSAGE_DISABLED is set to 'true'", () => { process.env.TURBO_TELEMETRY_MESSAGE_DISABLED = "true"; const result = telemetryConfig.isTelemetryWarningEnabled(); @@ -321,7 +321,7 @@ describe("TelemetryConfig", () => { assert.equal(result, false); }); - test("should return true if TURBO_TELEMETRY_MESSAGE_DISABLED is not set", () => { + it("should return true if TURBO_TELEMETRY_MESSAGE_DISABLED is not set", () => { const result = telemetryConfig.isTelemetryWarningEnabled(); assert.equal(result, true); @@ -329,13 +329,13 @@ describe("TelemetryConfig", () => { }); describe("showAlert", () => { - test("should log the telemetry alert if conditions are met", (t) => { + it("should log the telemetry alert if conditions are met", (t) => { const mockLog = t.mock.method(console, "log"); telemetryConfig.showAlert(); assert.equal(mockLog.mock.calls.length, 6); }); - test("should not log the telemetry alert if conditions are not met", (t) => { + it("should not log the telemetry alert if conditions are not met", (t) => { const mockLog = t.mock.method(console, "log"); telemetryConfig = new TelemetryConfig({ @@ -354,7 +354,7 @@ describe("TelemetryConfig", () => { }); describe("enable", () => { - test("should set telemetry_enabled to true and write the config", (t) => { + it("should set telemetry_enabled to true and write the config", (t) => { const mockWriteFileSync = t.mock.method(fs, "writeFileSync"); telemetryConfig.enable(); @@ -368,7 +368,7 @@ describe("TelemetryConfig", () => { }); describe("disable", () => { - test("should set telemetry_enabled to false and write the config", (t) => { + it("should set telemetry_enabled to false and write the config", (t) => { const mockWriteFileSync = t.mock.method(fs, "writeFileSync"); telemetryConfig.disable(); @@ -382,7 +382,7 @@ describe("TelemetryConfig", () => { }); describe("alertShown", () => { - test("should return true if telemetry_alerted is defined", () => { + it("should return true if telemetry_alerted is defined", () => { telemetryConfig = new TelemetryConfig({ configPath: "/path/to/config.json", config: { @@ -398,7 +398,7 @@ describe("TelemetryConfig", () => { assert.equal(result, true); }); - test("should set telemetry_alerted to current date and write the config if telemetry_alerted is undefined", (t) => { + it("should set telemetry_alerted to current date and write the config if telemetry_alerted is undefined", (t) => { const mockWriteFileSync = mock.fn(); t.mock.method(fs, "writeFileSync", mockWriteFileSync); const result = telemetryConfig.alertShown(); @@ -414,7 +414,7 @@ describe("TelemetryConfig", () => { }); describe("oneWayHash", () => { - test("should call oneWayHashWithSalt with the input and telemetry_salt from the config", (t) => { + it("should call oneWayHashWithSalt with the input and telemetry_salt from the config", (t) => { const mockOneWayHashWithSalt = mock.fn(() => "hashed-value"); t.mock.method(utils, "oneWayHashWithSalt", mockOneWayHashWithSalt); @@ -430,7 +430,7 @@ describe("TelemetryConfig", () => { }); describe("isDebug", () => { - test("should return true if TURBO_TELEMETRY_DEBUG is set to '1'", () => { + it("should return true if TURBO_TELEMETRY_DEBUG is set to '1'", () => { process.env.TURBO_TELEMETRY_DEBUG = "1"; const result = TelemetryConfig.isDebug(); @@ -438,7 +438,7 @@ describe("TelemetryConfig", () => { assert.equal(result, true); }); - test("should return true if TURBO_TELEMETRY_DEBUG is set to 'true'", () => { + it("should return true if TURBO_TELEMETRY_DEBUG is set to 'true'", () => { process.env.TURBO_TELEMETRY_DEBUG = "true"; const result = TelemetryConfig.isDebug(); @@ -446,7 +446,7 @@ describe("TelemetryConfig", () => { assert.equal(result, true); }); - test("should return false if TURBO_TELEMETRY_DEBUG is not set", () => { + it("should return false if TURBO_TELEMETRY_DEBUG is not set", () => { const result = TelemetryConfig.isDebug(); assert.equal(result, false); diff --git a/packages/turbo-telemetry/src/utils.test.ts b/packages/turbo-telemetry/src/utils.test.ts index ce62f367b69b9..81d4861beb842 100644 --- a/packages/turbo-telemetry/src/utils.test.ts +++ b/packages/turbo-telemetry/src/utils.test.ts @@ -1,10 +1,10 @@ -import { describe, test } from "node:test"; +import { describe, it } from "node:test"; import { strict as assert } from "node:assert"; import utils from "./utils"; describe("utils", () => { describe("oneWayHashWithSalt", () => { - test("should return the hashed value with salt", () => { + it("should return the hashed value with salt", () => { const input = "a-sensitive-value"; const salt = "private-salt"; @@ -15,7 +15,7 @@ describe("utils", () => { ); }); - test("should return consistent length", () => { + it("should return consistent length", () => { const input = "a-sensitive-value"; const salt = "private-salt"; @@ -30,7 +30,7 @@ describe("utils", () => { }); describe("defaultConfigPath", () => { - test("supports overriding by env var", async () => { + it("supports overriding by env var", async () => { process.env.TURBO_CONFIG_DIR_PATH = "/tmp"; const result = await utils.defaultConfigPath(); assert.equal(result, "/tmp/turborepo/telemetry.json"); diff --git a/packages/turbo-test-utils/package.json b/packages/turbo-test-utils/package.json index 6689dc0133511..482be4027d6e2 100644 --- a/packages/turbo-test-utils/package.json +++ b/packages/turbo-test-utils/package.json @@ -22,13 +22,14 @@ "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettier-ignore" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/tsconfig": "workspace:*", "@types/fs-extra": "^9.0.13", - "@types/jest": "^29.5.13", "@types/js-yaml": "^4.0.5", "@types/node": "^18.17.2", "jest": "^29.7.0", + "jest-mock": "^29.7.0", "ts-jest": "^29.2.5", "typescript": "5.4.5" }, diff --git a/packages/turbo-test-utils/src/mockEnv.ts b/packages/turbo-test-utils/src/mockEnv.ts index ee8be377e683a..0104925cec3b7 100644 --- a/packages/turbo-test-utils/src/mockEnv.ts +++ b/packages/turbo-test-utils/src/mockEnv.ts @@ -1,3 +1,5 @@ +import { afterAll, beforeEach, jest } from "@jest/globals"; + export function mockEnv() { const OLD_ENV = process.env; diff --git a/packages/turbo-test-utils/src/spyConsole.ts b/packages/turbo-test-utils/src/spyConsole.ts index 9f5fee2fa9a74..e0728b652f387 100644 --- a/packages/turbo-test-utils/src/spyConsole.ts +++ b/packages/turbo-test-utils/src/spyConsole.ts @@ -1,9 +1,10 @@ -export type Spy = jest.SpyInstance | undefined; +import { afterAll, afterEach, jest, beforeEach } from "@jest/globals"; +import type { SpyInstance } from "jest-mock"; export interface SpyConsole { - log: Spy; - error: Spy; - warn: Spy; + log: SpyInstance | undefined; + error: SpyInstance | undefined; + warn: SpyInstance | undefined; } export function spyConsole() { diff --git a/packages/turbo-test-utils/src/spyExit.ts b/packages/turbo-test-utils/src/spyExit.ts index a8e6c19ececd4..78d9ca721e906 100644 --- a/packages/turbo-test-utils/src/spyExit.ts +++ b/packages/turbo-test-utils/src/spyExit.ts @@ -1,7 +1,8 @@ -type Spy = jest.SpyInstance | undefined; +import { afterAll, afterEach, beforeEach, jest } from "@jest/globals"; +import type { MockInstance } from "jest-mock"; export interface SpyExit { - exit: Spy; + exit: MockInstance<(code?: number) => never> | undefined; } export function spyExit() { diff --git a/packages/turbo-test-utils/src/useFixtures.ts b/packages/turbo-test-utils/src/useFixtures.ts index 37b43fa49548a..1d87a5aa9d7fa 100644 --- a/packages/turbo-test-utils/src/useFixtures.ts +++ b/packages/turbo-test-utils/src/useFixtures.ts @@ -10,6 +10,7 @@ import { } from "fs-extra"; import yaml from "js-yaml"; import { parse as JSON5Parse } from "json5"; +import { afterAll, afterEach } from "@jest/globals"; interface SetupTextFixtures { directory: string; diff --git a/packages/turbo-test-utils/src/validateLogs.ts b/packages/turbo-test-utils/src/validateLogs.ts index ca52ad3383526..8e11015fa7568 100644 --- a/packages/turbo-test-utils/src/validateLogs.ts +++ b/packages/turbo-test-utils/src/validateLogs.ts @@ -1,21 +1,13 @@ -import type { Spy } from "./spyConsole"; +import { expect } from "@jest/globals"; +import type { SpyConsole } from "./spyConsole"; + +type Matcher = ReturnType; export function validateLogs( - logs: Array boolean | Array)>, - mockConsole: Spy, - options: { prefix?: string } = {} + spy: SpyConsole[keyof SpyConsole], + args: Array> ) { - logs.forEach((log, idx) => { - if (typeof log === "function") { - const expected = log(); - expect(mockConsole).toHaveBeenNthCalledWith( - idx + 1, - ...(Array.isArray(expected) ? expected : [expected]) - ); - } else if (options.prefix) { - expect(mockConsole).toHaveBeenNthCalledWith(idx + 1, options.prefix, log); - } else { - expect(mockConsole).toHaveBeenNthCalledWith(idx + 1, log); - } + args.forEach((arg, idx) => { + expect(spy).toHaveBeenNthCalledWith(idx + 1, ...arg); }); } diff --git a/packages/turbo-utils/__tests__/convertCase.test.ts b/packages/turbo-utils/__tests__/convertCase.test.ts index a52ccfd180160..487714ade5218 100644 --- a/packages/turbo-utils/__tests__/convertCase.test.ts +++ b/packages/turbo-utils/__tests__/convertCase.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect } from "@jest/globals"; import { convertCase, type CaseOptions } from "../src/convertCase"; interface TestCase { diff --git a/packages/turbo-utils/__tests__/examples.test.ts b/packages/turbo-utils/__tests__/examples.test.ts index 9386b9415eb77..b607c40d6f05d 100644 --- a/packages/turbo-utils/__tests__/examples.test.ts +++ b/packages/turbo-utils/__tests__/examples.test.ts @@ -1,8 +1,9 @@ import got from "got"; import * as Got from "got"; +import { describe, it, expect, jest } from "@jest/globals"; import { isUrlOk, getRepoInfo, hasRepo } from "../src/examples"; -jest.mock("got", () => ({ +jest.mock("got", () => ({ __esModule: true, ...jest.requireActual("got"), })); @@ -37,7 +38,7 @@ describe("examples", () => { }); describe("getRepoInfo", () => { - test.each([ + it.each([ { repoUrl: "https://github.com/vercel/turborepo/", examplePath: undefined, @@ -104,7 +105,7 @@ describe("examples", () => { }); describe("hasRepo", () => { - test.each([ + it.each([ { repoInfo: { username: "vercel", diff --git a/packages/turbo-utils/__tests__/getTurboConfigs.test.ts b/packages/turbo-utils/__tests__/getTurboConfigs.test.ts index cc96fee5484af..de4bc8a0d3885 100644 --- a/packages/turbo-utils/__tests__/getTurboConfigs.test.ts +++ b/packages/turbo-utils/__tests__/getTurboConfigs.test.ts @@ -1,5 +1,6 @@ import path from "node:path"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; import { getTurboConfigs } from "../src/getTurboConfigs"; describe("getTurboConfigs", () => { diff --git a/packages/turbo-utils/__tests__/getTurboRoot.test.ts b/packages/turbo-utils/__tests__/getTurboRoot.test.ts index 94dffc38905eb..4ff3d0631b758 100644 --- a/packages/turbo-utils/__tests__/getTurboRoot.test.ts +++ b/packages/turbo-utils/__tests__/getTurboRoot.test.ts @@ -1,6 +1,7 @@ -import path from "path"; -import { getTurboRoot } from "../src/getTurboRoot"; +import path from "node:path"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; +import { getTurboRoot } from "../src/getTurboRoot"; describe("getTurboConfigs", () => { const { useFixture } = setupTestFixtures({ @@ -8,7 +9,7 @@ describe("getTurboConfigs", () => { test: "common", }); - test.each([[""], ["child"]])( + it.each([[""], ["child"]])( "finds the root in a non-monorepo (%s)", (repoPath) => { const { root } = useFixture({ fixture: `single-package` }); @@ -17,7 +18,7 @@ describe("getTurboConfigs", () => { } ); - test.each([ + it.each([ [""], ["apps"], ["apps/docs"], diff --git a/packages/turbo-utils/__tests__/isFolderEmpty.test.ts b/packages/turbo-utils/__tests__/isFolderEmpty.test.ts index b766f8278c690..80e8a1c3c487d 100644 --- a/packages/turbo-utils/__tests__/isFolderEmpty.test.ts +++ b/packages/turbo-utils/__tests__/isFolderEmpty.test.ts @@ -1,7 +1,8 @@ +import path from "node:path"; import fs from "fs-extra"; -import path from "path"; -import { isFolderEmpty } from "../src/isFolderEmpty"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect } from "@jest/globals"; +import { isFolderEmpty } from "../src/isFolderEmpty"; describe("isFolderEmpty", () => { const { useFixture } = setupTestFixtures({ diff --git a/packages/turbo-utils/__tests__/isWritable.test.ts b/packages/turbo-utils/__tests__/isWritable.test.ts index 1544cbcb5b48c..de0b6d93f8686 100644 --- a/packages/turbo-utils/__tests__/isWritable.test.ts +++ b/packages/turbo-utils/__tests__/isWritable.test.ts @@ -1,7 +1,8 @@ -import path from "path"; -import { isWriteable } from "../src/isWriteable"; -import { setupTestFixtures } from "@turbo/test-utils"; +import path from "node:path"; import fs from "fs-extra"; +import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; +import { isWriteable } from "../src/isWriteable"; describe("isWriteable", () => { const { useFixture } = setupTestFixtures({ diff --git a/packages/turbo-utils/package.json b/packages/turbo-utils/package.json index 82f5bb6d5b06e..5ae64a8dbfdf0 100644 --- a/packages/turbo-utils/package.json +++ b/packages/turbo-utils/package.json @@ -25,6 +25,7 @@ "lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@manypkg/find-root": "^1.1.0", "@turbo/eslint-config": "workspace:*", "@turbo/test-utils": "workspace:*", @@ -33,7 +34,6 @@ "@types/async-retry": "^1.4.5", "@types/fs-extra": "^9.0.13", "@types/gradient-string": "^1.1.2", - "@types/jest": "^29.5.13", "@types/js-yaml": "^4.0.5", "@types/node": "^20.5.7", "@types/tar": "^6.1.4", diff --git a/packages/turbo-workspaces/__tests__/index.test.ts b/packages/turbo-workspaces/__tests__/index.test.ts index 623ea72aed569..7efa709643958 100644 --- a/packages/turbo-workspaces/__tests__/index.test.ts +++ b/packages/turbo-workspaces/__tests__/index.test.ts @@ -1,9 +1,10 @@ -import path from "path"; +import path from "node:path"; +import execa from "execa"; import * as turboUtils from "@turbo/utils"; import { setupTestFixtures } from "@turbo/test-utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { getWorkspaceDetails, convert } from "../src"; import { generateConvertMatrix } from "./test-utils"; -import execa from "execa"; jest.mock("execa", () => jest.fn()); @@ -13,7 +14,7 @@ describe("Node entrypoint", () => { }); describe("convert", () => { - test.each(generateConvertMatrix())( + it.each(generateConvertMatrix())( "detects $fixtureType project using $fixtureManager and converts to $toManager (interactive=$interactive dry=$dry install=$install)", async ({ fixtureManager, diff --git a/packages/turbo-workspaces/__tests__/managers.test.ts b/packages/turbo-workspaces/__tests__/managers.test.ts index 734b42d2fa6cd..84c09eef77742 100644 --- a/packages/turbo-workspaces/__tests__/managers.test.ts +++ b/packages/turbo-workspaces/__tests__/managers.test.ts @@ -2,6 +2,7 @@ import path from "node:path"; import { ensureDirSync, existsSync } from "fs-extra"; import { setupTestFixtures } from "@turbo/test-utils"; import type { PackageJson } from "@turbo/utils"; +import { describe, it, expect, jest } from "@jest/globals"; import { Logger } from "../src/logger"; import { MANAGERS } from "../src/managers"; import { @@ -21,7 +22,7 @@ describe("managers", () => { }); describe("detect", () => { - test.each(generateDetectMatrix())( + it.each(generateDetectMatrix())( "$project $type project detected by $manager manager - (expect: $result)", async ({ project, manager, type, result }) => { const { root } = useFixture({ fixture: `./${project}/${type}` }); @@ -36,7 +37,7 @@ describe("managers", () => { }); describe("create", () => { - test.each(generateCreateMatrix())( + it.each(generateCreateMatrix())( "creates $manager project from $project $type project (interactive=$interactive, dry=$dry)", async ({ project, manager, type, interactive, dry }) => { expect.assertions(2); @@ -72,7 +73,7 @@ describe("managers", () => { }); describe("remove", () => { - test.each(generateRemoveMatrix())( + it.each(generateRemoveMatrix())( "removes $fixtureManager from $fixtureManager $fixtureType project when moving to $toManager (withNodeModules=$withNodeModules, interactive=$interactive, dry=$dry)", async ({ fixtureManager, @@ -154,7 +155,7 @@ describe("managers", () => { }); describe("read", () => { - test.each(generateReadMatrix())( + it.each(generateReadMatrix())( "reads $toManager workspaces from $fixtureManager $fixtureType project - (shouldThrow: $shouldThrow)", async ({ fixtureManager, fixtureType, toManager, shouldThrow }) => { const { root, directoryName } = useFixture({ @@ -226,7 +227,7 @@ describe("managers", () => { }); describe("read - alternate workspace format", () => { - test.each(generateReadMatrix())( + it.each(generateReadMatrix())( "reads $toManager workspaces using alternate format from $fixtureManager $fixtureType project - (shouldThrow: $shouldThrow)", async ({ fixtureManager, fixtureType, toManager, shouldThrow }) => { const { root, directoryName, readJson, write } = useFixture({ @@ -308,7 +309,7 @@ describe("managers", () => { }); describe("clean", () => { - test.each(generateCleanMatrix())( + it.each(generateCleanMatrix())( "cleans $fixtureManager $fixtureType project (interactive=$interactive, dry=$dry)", async ({ fixtureManager, fixtureType, interactive, dry }) => { const { root } = useFixture({ @@ -336,7 +337,7 @@ describe("managers", () => { }); describe("convertLock", () => { - test.each(generateConvertLockMatrix())( + it.each(generateConvertLockMatrix())( "converts lockfile for $fixtureManager $fixtureType project to $toManager format (interactive=$interactive, dry=$dry)", async ({ fixtureManager, fixtureType, toManager, interactive, dry }) => { const { root, exists } = useFixture({ diff --git a/packages/turbo-workspaces/__tests__/utils.test.ts b/packages/turbo-workspaces/__tests__/utils.test.ts index 868f0802c0d8c..a3d10cc7d814e 100644 --- a/packages/turbo-workspaces/__tests__/utils.test.ts +++ b/packages/turbo-workspaces/__tests__/utils.test.ts @@ -1,9 +1,10 @@ +import { describe, it, expect } from "@jest/globals"; import type { Project } from "../src/types"; import { isCompatibleWithBunWorkspaces } from "../src/utils"; describe("utils", () => { describe("isCompatibleWithBunWorkspace", () => { - test.each([ + it.each([ { globs: ["apps/*"], expected: true }, { globs: ["apps/*", "packages/*"], expected: true }, { globs: ["*"], expected: true }, diff --git a/packages/turbo-workspaces/package.json b/packages/turbo-workspaces/package.json index 2e00608918641..68acc961195c2 100644 --- a/packages/turbo-workspaces/package.json +++ b/packages/turbo-workspaces/package.json @@ -39,6 +39,7 @@ "update-check": "^1.5.4" }, "devDependencies": { + "@jest/globals": "^29.7.0", "@turbo/eslint-config": "workspace:*", "@turbo/test-utils": "workspace:*", "@turbo/tsconfig": "workspace:*", @@ -46,7 +47,6 @@ "@types/fs-extra": "^9.0.13", "@types/gradient-string": "^1.1.2", "@types/inquirer": "^7.3.1", - "@types/jest": "^29.5.13", "@types/js-yaml": "^4.0.5", "@types/node": "^18.17.2", "@types/rimraf": "^3.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8bd342124db7d..63e0fe08675d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,6 +115,9 @@ importers: specifier: ^1.5.4 version: 1.5.4 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -139,9 +142,6 @@ importers: '@types/inquirer': specifier: ^7.3.1 version: 7.3.3 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^18.17.2 version: 18.17.4 @@ -192,6 +192,9 @@ importers: specifier: '>6.6.0' version: 8.47.0 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -213,9 +216,6 @@ importers: '@types/estree': specifier: ^1.0.0 version: 1.0.0 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^18.17.2 version: 18.17.4 @@ -287,6 +287,9 @@ importers: specifier: ^5.27.0 version: 5.27.0 devDependencies: + '@jest/globals': + specifier: 29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -360,6 +363,9 @@ importers: specifier: ^1.5.4 version: 1.5.4 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -393,9 +399,6 @@ importers: '@types/inquirer': specifier: ^8.2.0 version: 8.2.5 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^18.17.2 version: 18.17.4 @@ -462,6 +465,9 @@ importers: specifier: ^5.0.0 version: 5.0.0 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -480,9 +486,6 @@ importers: '@types/inquirer': specifier: ^8.2.5 version: 8.2.5 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^18.17.2 version: 18.17.4 @@ -508,6 +511,9 @@ importers: specifier: ^2.2.3 version: 2.2.3 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -526,9 +532,6 @@ importers: '@turbo/utils': specifier: workspace:* version: link:../turbo-utils - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/node': specifier: ^18.17.2 version: 18.17.4 @@ -624,6 +627,9 @@ importers: specifier: ^2.2.3 version: 2.2.3 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -633,9 +639,6 @@ importers: '@types/fs-extra': specifier: ^9.0.13 version: 9.0.13 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/js-yaml': specifier: ^4.0.5 version: 4.0.5 @@ -645,6 +648,9 @@ importers: jest: specifier: ^29.7.0 version: 29.7.0(@types/node@18.17.4) + jest-mock: + specifier: ^29.7.0 + version: 29.7.0 ts-jest: specifier: ^29.2.5 version: 29.2.5(@babel/core@7.25.2)(esbuild@0.14.49)(jest@29.7.0)(typescript@5.4.5) @@ -672,6 +678,9 @@ importers: packages/turbo-utils: devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@manypkg/find-root': specifier: ^1.1.0 version: 1.1.0 @@ -696,9 +705,6 @@ importers: '@types/gradient-string': specifier: ^1.1.2 version: 1.1.2 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/js-yaml': specifier: ^4.0.5 version: 4.0.5 @@ -812,6 +818,9 @@ importers: specifier: ^1.5.4 version: 1.5.4 devDependencies: + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@turbo/eslint-config': specifier: workspace:* version: link:../eslint-config @@ -833,9 +842,6 @@ importers: '@types/inquirer': specifier: ^7.3.1 version: 7.3.3 - '@types/jest': - specifier: ^29.5.13 - version: 29.5.13 '@types/js-yaml': specifier: ^4.0.5 version: 4.0.5 @@ -2997,13 +3003,6 @@ packages: '@types/istanbul-lib-report': 3.0.0 dev: true - /@types/jest@29.5.13: - resolution: {integrity: sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg==} - dependencies: - expect: 29.7.0 - pretty-format: 29.7.0 - dev: true - /@types/js-yaml@4.0.5: resolution: {integrity: sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==} dev: true