v0.13.7
errors and warnings / stdlib

errors and warnings / stdlib / E8123

E8123 error

mock.module replaces an export the module does not have

area
stdlib (x8xxx)
fails the build
yes

mock.module replaces an export that the module doesn't have. The replacement table is checked against the module's exports: a name the module doesn't export is E8123, and a replacement of the wrong type is a type error. Usually the name is misspelled, or the export was renamed.

Example

× failssrc/clock.wowluawowlua
export function now(): number    return GetTime()end
tests/clock.test.wowluawowlua
import test, expect from "wowlua:test"import * as mock from "wowlua:mock"import * as clock from "/clock" mock.module(clock, { today = function(): number return 0 end }) @test("reads the clock")local function reads()    expect(clock.now()).toBe(0)end
✓ compilessrc/clock.wowluawowlua
export function now(): number    return GetTime()end
tests/clock.test.wowluawowlua
import test, expect from "wowlua:test"import * as mock from "wowlua:mock"import * as clock from "/clock" mock.module(clock, { now = function(): number return 0 end }) @test("reads the clock")local function reads()    expect(clock.now()).toBe(0)end

The compiler reports it like this:

error[E8123]: the module has no export `today`
  ┌─ tests/clock.test.wowlua:5:22
  │
5 │ mock.module(clock, { today = function(): number return 0 end })
  │                      ^^^^^ here
codemessage
E8119import internal outside a test file

Offline

terminal
$ wowlua explain E8123
E8123 (error): mock.module replaces an export the module does not have

source on GitHub ↗