Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { test } from 'node:test'

function getOutput() {
const result = spawnSync('npm', ['start', '--silent'], { encoding: 'utf8' })
import { getNpmStartOutput } from '../run-npm-start.ts'

if (result.error) {
throw result.error
}

assert.strictEqual(
result.status,
0,
result.stderr || '🚨 Running the program failed',
)

return result.stdout.replace(/\r\n/g, '\n')
}

const output = getOutput()
const output = getNpmStartOutput()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playground missing shared test helper

High Severity

Solution tests now import getNpmStartOutput from ../run-npm-start.ts, but the Epic Shop playground only receives copied *.test.ts files into a flat playground/ directory. That relative import resolves outside the playground and the helper file is not present, so npm test in the playground fails to load the module for exercises 2–5.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0aed4d1. Configure here.


await test('should print apostrophe string', () => {
assert.ok(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { test } from 'node:test'

function getOutput() {
const result = spawnSync('npm', ['start', '--silent'], { encoding: 'utf8' })
import { getNpmStartOutput } from '../run-npm-start.ts'

if (result.error) {
throw result.error
}

assert.strictEqual(
result.status,
0,
result.stderr || '🚨 Running the program failed',
)

return result.stdout.replace(/\r\n/g, '\n')
}

const output = getOutput()
const output = getNpmStartOutput()

await test('should print Hello TypeScript', () => {
assert.ok(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { test } from 'node:test'

function getOutput() {
const result = spawnSync('npm', ['start', '--silent'], { encoding: 'utf8' })
import { getNpmStartOutput } from '../run-npm-start.ts'

if (result.error) {
throw result.error
}

assert.strictEqual(
result.status,
0,
result.stderr || '🚨 Running the program failed',
)

return result.stdout.replace(/\r\n/g, '\n')
}

const output = getOutput()
const output = getNpmStartOutput()
const lines = output
.split('\n')
.map((line) => line.trim())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { test } from 'node:test'

function getOutput() {
const result = spawnSync('npm', ['start', '--silent'], { encoding: 'utf8' })
import { getNpmStartOutput } from '../run-npm-start.ts'

if (result.error) {
throw result.error
}

assert.strictEqual(
result.status,
0,
result.stderr || '🚨 Running the program failed',
)

return result.stdout.replace(/\r\n/g, '\n')
}

const output = getOutput()
const output = getNpmStartOutput()

await test('should print "The answer is 42"', () => {
assert.ok(
Expand Down
21 changes: 21 additions & 0 deletions exercises/01.expressions-and-output/run-npm-start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'

export function getNpmStartOutput() {
const result = spawnSync('npm', ['start', '--silent'], {
encoding: 'utf8',
shell: true,
})

if (result.error) {
throw result.error
}

assert.strictEqual(
result.status,
0,
result.stderr || '🚨 Running the program failed',
)

return result.stdout.replace(/\r\n/g, '\n')
}
Loading