const Gpio = require('onoff').Gpio; const action = require('./action-on-gpio'); // https://stackoverflow.com/questions/51418086/jest-expected-mock-function-to-have-been-called-but-it-was-not-called describe('integration test', () => { it('should publish mqtt when GPIO goes high', () => { const button = { readSync: jest.fn(() => Gpio.LOW)} const client = { publish: jest.fn()} action.pubMqttOnGpio(button, client); expect(button.readSync).toHaveBeenCalledTimes(1) expect(client.publish).toHaveBeenCalledTimes(1) expect(client.publish).toBeCalledWith('button/islow', '{true}', {qos: 1}) }) })