Mock event is empty during local invokation of function

I started my own project off of the Serverless template and I got a basic “hello, World!” GET endpoint working locally. However, I went in and tried to add an event variable (body) and pass it via a mock event and somehow the event is not recognized by Serverless.

service: myservice-api
package:
    individually: true
plugins:
    - serverless-bundle
    - serverless-dotenv-plugin
    - serverless-offline
provider:
    name: aws
    runtime: nodejs12.x
    stage: dev
    region: us-east-2
functions:
    helloWorld:
        handler: helloWorld.main
        events:
            - http:
                path: myservice
                method: get
                cors: true
                authorizer: aws_iam
resources:
    - ${file(resources/apiGatewayCORSResponses.yml)}

export function main(event, context, callback) {
	console.log(JSON.stringify(event));
	const headers = {
		"Access-Control-Allow-Origin": "*",
		"Access-Control-Allow-Credentials": true
	};
	const response = {
		statusCode: 200,
		headers: headers,
		body: event.body
	};
	callback(null, response);
};
{
	body: "Hello, World!"
}

When I run serverless invoke local --function helloWorld --path mocks/helloWorld.js, I get this:

{}
{
    "statusCode": 200,
    "headers": {
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Allow-Credentials": true
    }
}

As in, the event object is empty even though I clearly passed something that works fine!
Note: my environment looks like this and this started happening after I updated my Serverless install so that might be the problem…

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.1.0
     Framework Version:         1.69.0
     Plugin Version:            3.6.9
     SDK Version:               2.3.0
     Components Version:        2.30.5

I figured it out, a mock event should be a JSON, not a JS file, which would not be parsed successfully because it’s not a JSON file.

Ah that makes sense. Glad you figured it out.