MCPcopy Create free account
hub / github.com/nodejs/node / mockWorkspaces

Function mockWorkspaces

deps/npm/test/lib/commands/run.js:510–586  ·  view source on GitHub ↗
(t, {
    runScript,
    prefixDir,
    workspaces = true,
    exec = [],
    chdir = ({ prefix }) => prefix,
    ...config
  } = {})

Source from the content-addressed store, hash-verified

508
509t.test('workspaces', async t => {
510 const mockWorkspaces = async (t, {
511 runScript,
512 prefixDir,
513 workspaces = true,
514 exec = [],
515 chdir = ({ prefix }) => prefix,
516 ...config
517 } = {}) => {
518 const mock = await mockRs(t, {
519 prefixDir: prefixDir || {
520 packages: {
521 a: {
522 'package.json': JSON.stringify({
523 name: 'a',
524 version: '1.0.0',
525 scripts: { glorp: 'echo a doing the glerp glop' },
526 }),
527 },
528 b: {
529 'package.json': JSON.stringify({
530 name: 'b',
531 version: '2.0.0',
532 scripts: { glorp: 'echo b doing the glerp glop' },
533 }),
534 },
535 c: {
536 'package.json': JSON.stringify({
537 name: 'c',
538 version: '1.0.0',
539 scripts: {
540 test: 'exit 0',
541 posttest: 'echo posttest',
542 lorem: 'echo c lorem',
543 },
544 }),
545 },
546 d: {
547 'package.json': JSON.stringify({
548 name: 'd',
549 version: '1.0.0',
550 scripts: {
551 test: 'exit 0',
552 posttest: 'echo posttest',
553 },
554 }),
555 },
556 e: {
557 'package.json': JSON.stringify({
558 name: 'e',
559 scripts: { test: 'exit 0', start: 'echo start something' },
560 }),
561 },
562 noscripts: {
563 'package.json': JSON.stringify({
564 name: 'noscripts',
565 version: '1.0.0',
566 }),
567 },

Callers 1

run.jsFile · 0.70

Calls 2

mockRsFunction · 0.85
execMethod · 0.45

Tested by

no test coverage detected