mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-29 12:31:52 -04:00
* test: create new @pnpm/test-ipc-server private util package * test: use @pnpm/test-ipc-server for previously refactored tests * test: use @pnpm/test-ipc-server for tests using json-append * test: change how --no-bail is passed to avoid passing it to scripts This test began failing after the conversion to use `@pnpm/test-echo-server` since the `--no-bail` script was being passed to scripts. Changing how --no-bail is configured to fix this test. * test: use @pnpm/test-ipc-server in exec/lifecycle fixture tests * test: use @pnpm/test-ipc-server in pkg-manager/headless fixture tests * test: use @pnpm/test-ipc-server in exec/prepare-package fixture tests * test: switch pnpm test from json-append to @pnpm.e2e/hello-world-js-bin * test: fix and re-enable 'rebuild multiple packages in correct order' The pnpm-workspace.yaml file didn't contain all packages, causing: ``` 2023-12-22T02:24:46.2277155Z FAIL test/recursive.ts 2023-12-22T02:24:46.2277881Z ● rebuild multiple packages in correct order 2023-12-22T02:24:46.2278348Z 2023-12-22T02:24:46.2278734Z expect(received).toStrictEqual(expected) // deep equality 2023-12-22T02:24:46.2279302Z 2023-12-22T02:24:46.2279517Z - Expected - 1 2023-12-22T02:24:46.2279932Z + Received + 0 2023-12-22T02:24:46.2280186Z 2023-12-22T02:24:46.2280791Z Array [ 2023-12-22T02:24:46.2281256Z "project-1", 2023-12-22T02:24:46.2281733Z - "project-2", 2023-12-22T02:24:46.2282135Z ] 2023-12-22T02:24:46.2282334Z 2023-12-22T02:24:46.2282475Z 216 | }, []) 2023-12-22T02:24:46.2282870Z 217 | 2023-12-22T02:24:46.2283788Z > 218 | expect(server1.getMessages()).toStrictEqual(['project-1', 'project-2']) 2023-12-22T02:24:46.2284725Z | ^ 2023-12-22T02:24:46.2285802Z 219 | expect(server2.getMessages()).toStrictEqual(['project-1', 'project-3']) 2023-12-22T02:24:46.2286683Z 220 | }) 2023-12-22T02:24:46.2287049Z 221 | 2023-12-22T02:24:46.2287269Z 2023-12-22T02:24:46.2287588Z at Object.<anonymous> (test/recursive.ts:218:33) ```
101 lines
2.4 KiB
TypeScript
101 lines
2.4 KiB
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import { preparePackages, tempDir } from '@pnpm/prepare'
|
|
import { fixtures } from '@pnpm/test-fixtures'
|
|
import {
|
|
type MutatedProject,
|
|
mutateModules,
|
|
install,
|
|
} from '@pnpm/core'
|
|
import { testDefaults } from '../utils'
|
|
|
|
const f = fixtures(__dirname)
|
|
|
|
test('jest CLI should print the right version when multiple instances of jest are used in a workspace', async () => {
|
|
preparePackages([
|
|
{
|
|
location: 'project-1',
|
|
package: { name: 'project-1' },
|
|
},
|
|
{
|
|
location: 'project-2',
|
|
package: { name: 'project-2' },
|
|
},
|
|
])
|
|
const importers: MutatedProject[] = [
|
|
{
|
|
mutation: 'install',
|
|
rootDir: path.resolve('project-1'),
|
|
},
|
|
{
|
|
mutation: 'install',
|
|
rootDir: path.resolve('project-2'),
|
|
},
|
|
]
|
|
const allProjects = [
|
|
{
|
|
buildIndex: 0,
|
|
manifest: {
|
|
name: 'project-1',
|
|
version: '1.0.0',
|
|
scripts: {
|
|
postinstall: 'jest --version > output.json',
|
|
},
|
|
|
|
dependencies: {
|
|
jest: '27.5.1',
|
|
},
|
|
},
|
|
rootDir: path.resolve('project-1'),
|
|
},
|
|
{
|
|
buildIndex: 0,
|
|
manifest: {
|
|
name: 'project-2',
|
|
version: '1.0.0',
|
|
scripts: {
|
|
postinstall: 'jest --version > output.json',
|
|
},
|
|
|
|
dependencies: {
|
|
jest: '24.9.0',
|
|
},
|
|
},
|
|
rootDir: path.resolve('project-2'),
|
|
},
|
|
]
|
|
await mutateModules(importers, await testDefaults({
|
|
allProjects,
|
|
extendNodePath: true,
|
|
fastUnpack: false,
|
|
hoistPattern: '*',
|
|
}))
|
|
|
|
{
|
|
const jestVersion = fs.readFileSync('project-1/output.json').toString()
|
|
expect(jestVersion.trim()).toStrictEqual('27.5.1')
|
|
}
|
|
{
|
|
const jestVersion = fs.readFileSync('project-2/output.json').toString()
|
|
expect(jestVersion.trim()).toStrictEqual('24.9.0')
|
|
}
|
|
})
|
|
|
|
test('drupal-js-build should find plugins inside the hidden node_modules directory', async () => {
|
|
const tmp = tempDir()
|
|
f.copy('tooling-that-needs-node-path', tmp)
|
|
await install({
|
|
dependencies: {
|
|
'drupal-js-build': 'github:pnpm-e2e/drupal-js-build#f766801580f10543c24ba8bfa59046a776848097',
|
|
},
|
|
scripts: {
|
|
prepare: 'drupal-js-build',
|
|
},
|
|
}, await testDefaults({
|
|
extendNodePath: true,
|
|
fastUnpack: false,
|
|
hoistPattern: '*',
|
|
}))
|
|
expect(fs.existsSync(path.join(tmp, 'index.js'))).toBeTruthy()
|
|
})
|