Preheat the oven to 400°F. Grease a 2-quart baking dish with olive oil.
Heat the olive oil in a large, deep skillet over medium-high heat. Add the mushrooms, onions, and kosher salt. Cook, stirring occasionally, until the mushrooms have released their liquid and the liquids have mostly evaporated, about 10 minutes.
¼ cup olive oil, 32 ounces baby Bella or crimini mushrooms, 1 cup onions, 2 teaspoons Diamond Crystal kosher salt
Add the garlic, black pepper, and thyme. Cook, stirring, for one more minute. Remove from heat.
1 tablespoon fresh garlic, ½ teaspoon black pepper, ½ teaspoon dried thyme
Transfer the mixture to the prepared baking dish. Sprinkle it with the shredded cheese.
1 cup Gruyere cheese
Bake the casserole until hot and bubbly, about 15 minutes. Sprinkle with parsley and serve.
1 teaspoon dried parsley
Video
Notes
If your casserole dish is broiler-safe, instead of baking, you can simply broil the casserole for 2-3 minutes in the middle of the oven until the cheese is melted. You don't want to get too close to the heating element and risk burning the casserole.
Seasonings, especially salt, are guidelines. Adjust to taste.
I use a lot of mushrooms - 32 ounces. But keep in mind that mushrooms lose significant volume after they are cooked. Once cooked, they fit nicely in a 2-quart casserole dish.
I like to use brown mushrooms because they make the casserole look more presentable than white mushrooms. So, I typically use baby Bella or crimini mushrooms.
Once the leftovers are cool, transfer them with a slotted spoon to an airtight container and keep them in the fridge for up to 4 days. Reheat them in the microwave at 50% power.