'AssertionError: expected [Function] to throw Error No events were emitted

I am trying to test if a modifier in my smart contract is throwing an error. My Smart contract funtion and modifier looks like this

function getPermissionedRegions(string memory _patientId) public view
        onlyPatient(_patientId) returns(string[] memory) {
        return patients[_patientId].permissionedRegions;
    }

modifier onlyPatient(string memory _patientId) {
        require(patients[_patientId].addr == msg.sender);
        _;
    }

My test looks like this:

it("getPermissionnedRegions throws an error when called by anybody else but the patient", async function () {
   var expect = require('chai').expect;
   expect(() => {
            instance.getPermissionedRegions.bind(instance, pat_gbg_kungalv, { from: pat_boras_account })
            }).to.throw(Error, "Function called by unauthorized actor");
        });

I am getting the following error: AssertionError: expected [Function] to throw Error

After searching for a bit on Stack Overflow I founf the bind() function should help with this but I am still stuck. I would appreciate any help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source