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,9 +1,27 @@
import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { test } from 'node:test'

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

const output = getNpmStartOutput()
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()

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

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

const output = getNpmStartOutput()
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()

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

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

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

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

const output = getNpmStartOutput()
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()

await test('should print "The answer is 42"', () => {
assert.ok(
Expand Down
21 changes: 0 additions & 21 deletions exercises/01.expressions-and-output/run-npm-start.ts

This file was deleted.

Loading