Skip to content

How to debug VMs #135

Open
Open
@Josef37

Description

@Josef37

I've been looking into #121 yesterday and tried to set up some tests to verify wrong/right behavior.

Therefore I had to create a few mocks in roomsSpec.js, but couldn't find out what these values should be.

My idea was to debug the script when its running to get some useful mocks, but I can't get my IDE (VSCode) to debug those...

I've seen there is a config option editor.enableInspector so I figured you have set this up once.
Can you help me set up debugging?


PS: That's where I'm currently at in terms of mocking values

let globals = {};

beforeEach(() => {
  const runtimeData = {
    staticTerrainData: require("../../helpers/mocks/rooms").terrain,
  };
  const register = {
    wrapFn: fn => fn,
    rooms: { E2S7: {} },
    _useNewPathFinder: true,
  };

  rooms.make(runtimeData, {}, register, globals);
  rooms.makePos(register);

  for (var i in runtimeData.rooms) {
    register.rooms[i] = new globals.Room(i);
  }
});

But calling RoomPosition.findClosestByPath still results in the following issue, since globals.PathFinder is not set.

Message:
    TypeError: Cannot read property 'search' of undefined
  Stack:
        at <Jasmine>
        at _findClosestByPath2 (/Users/josef/screeps/screeps-modules/engine/src/game/rooms.js:360:34)
        at RoomPosition.findClosestByPath (/Users/josef/screeps/screeps-modules/engine/src/game/rooms.js:1446:20)
        at UserContext.fit (/Users/josef/screeps/screeps-modules/engine/spec/engine/game/roomsSpec.js:70:28)
        at <Jasmine>
        at runCallback (timers.js:705:18)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions