• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 23995741899

05 Apr 2026 06:14AM UTC coverage: 77.093% (+0.002%) from 77.091%
23995741899

push

github

web-flow
Upgrade to TypeScript 6 and Prettier improvements (#1936)

* Upgrade TypeScript to v6

* Fix import source

* Fix tsconfig

* Fix preexisting type errors

* Remove scm-slang

* Bump node types

* Fix tsconfig

* Fix node types specifier

* Enable trailing commas

* Enable semicolons

* Check and commit files with changed line numbers

* Update Yarn to 4.13.0

* Remove unneeded sicp package deps

3112 of 4282 branches covered (72.68%)

Branch coverage included in aggregate %.

3761 of 5218 new or added lines in 152 files covered. (72.08%)

26 existing lines in 9 files now uncovered.

7136 of 9011 relevant lines covered (79.19%)

175254.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/utils/testing/mocks.ts
1
import type es from 'estree';
2

3
import createContext, { EnvTree } from '../../createContext';
4
import Closure from '../../cse-machine/closure';
5
import { createBlockEnvironment } from '../../cse-machine/utils';
6
import { Chapter, type LanguageOptions, Variant } from '../../langs';
7
import type { Context, Environment } from '../../types';
8

9
export function mockContext(
10
  chapter: Chapter = Chapter.SOURCE_1,
972✔
11
  variant: Variant = Variant.DEFAULT,
972✔
12
  languageOptions: LanguageOptions = {},
972✔
13
): Context {
14
  return createContext(chapter, variant, languageOptions);
972✔
15
}
16

17
export function mockImportDeclaration(): es.ImportDeclaration {
18
  const mockImportDecl: es.ImportDeclaration = {
×
19
    type: 'ImportDeclaration',
20
    specifiers: [
21
      {
22
        type: 'ImportDefaultSpecifier',
23
        local: {
24
          type: 'Identifier',
25
          name: 'MockName',
26
        },
27
      },
28
    ],
29
    source: {
30
      type: 'Literal',
31
      value: 'mock-path',
32
      raw: "'mock-path'",
33
    },
34
  };
NEW
35
  return mockImportDecl;
×
36
}
37

38
export function mockRuntimeContext(): Context {
39
  const context = createContext();
1,014✔
40
  context.runtime = {
1,014✔
41
    break: false,
42
    debuggerOn: true,
43
    isRunning: true,
44
    environmentTree: new EnvTree(),
45
    environments: [],
46
    nodes: [
47
      {
48
        type: 'Literal',
49
        loc: {
50
          start: { line: 1, column: 0 },
51
          end: { line: 1, column: 1 },
52
        },
53
        value: 0,
54
        raw: '0',
55
        range: [0, 1],
56
      },
57
    ],
58
    control: null,
59
    stash: null,
60
    objectCount: 0,
61
    envStepsTotal: 0,
62
    breakpointSteps: [],
63
    changepointSteps: [],
64
  };
65
  return context;
1,014✔
66
}
67

68
export function mockClosure(): Closure {
69
  const context = createContext();
3✔
70
  return new Closure(
3✔
71
    {
72
      type: 'ArrowFunctionExpression',
73
      expression: true,
74
      loc: null,
75
      params: [],
76
      body: {
77
        type: 'BlockStatement',
78
        body: [],
79
      },
80
    } as es.ArrowFunctionExpression,
81
    mockEnvironment(context),
82
    context,
83
  );
84
}
85

86
export function mockEnvironment(context: Context, name = 'blockEnvironment'): Environment {
11✔
87
  return createBlockEnvironment(context, name);
11✔
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc