Repository: babel/babel
File: packages/babel-traverse/test/modification.js (JavaScript)

Code before:
        const bodyPath = getPath("export function a() {}", {
          sourceType: "module",
        }).parentPath;
        const fnPath = bodyPath.get("body.0.declaration");
        fnPath.insertAfter(t.identifier("x"));

        expect(bodyPath.get("body")).toHaveLength(2);
        expect(bodyPath.get("body.1").node).toEqual(
          t.expressionStatement(t.identifier("x")),
        );
      });

      it("the ExportDefaultDeclaration, if a declaration is exported", function () {
        const bodyPath = getPath("export default function () {}", {
          sourceType: "module",
        }).parentPath;
        const fnPath = bodyPath.get("body.0.declaration");
        fnPath.insertAfter(t.identifier("x"));

        expect(bodyPath.get("body")).toHaveLength(2);
        expect(bodyPath.get("body.1").node).toEqual(
          t.expressionStatement(t.identifier("x")),
        );
      });

      it("edge case for babel-plugin-jest-hoist", function () {
        let varsHoistPoint;
        let i = 0;
        const logs = [[], []];
        traverse(parse(`{a;}`), {
          BlockStatement(path) {
            [varsHoistPoint] = path.unshiftContainer(
              "body",
              t.emptyStatement(),
            );
            path.traverse({
              Identifier(path) {
                if (i++ >= 5) {
                  return;
                }
                logs[0].push(path.node.name);
                varsHoistPoint.insertBefore(t.identifier("b"));
              },
            });
          },
        });
        i = 0;
        traverse(parse(`{a;}`), {
          BlockStatement(path) {
            [varsHoistPoint] = path.unshiftContainer(
              "body",

Review comment (suggestion):
Q: Why is the test "the exported expression" removed? The new test seems drastically different than the previous test.

Code after:
      it("the ExportNamedDeclaration", function () {
        const bodyPath = getPath("export function a() {}", {
          sourceType: "module",
        }).parentPath;
        const fnPath = bodyPath.get("body.0.declaration");
        fnPath.insertAfter(t.identifier("x"));

        expect(bodyPath.get("body")).toHaveLength(2);
        expect(bodyPath.get("body.1").node).toEqual(
          t.expressionStatement(t.identifier("x")),
        );
      });

      it("the ExportDefaultDeclaration, if a declaration is exported", function () {
        const bodyPath = getPath("export default function () {}", {
          sourceType: "module",
        }).parentPath;
        const fnPath = bodyPath.get("body.0.declaration");
        fnPath.insertAfter(t.identifier("x"));

        expect(bodyPath.get("body")).toHaveLength(2);
        expect(bodyPath.get("body.1").node).toEqual(
          t.expressionStatement(t.identifier("x")),
        );
      });

      it("the exported expression", function () {
        const bodyPath = getPath("export default fn();", {
          sourceType: "module",
        }).parentPath;
        const path = bodyPath.get("body.0.declaration");
        path.insertAfter(t.identifier("x"));

        expect(generateCode({ parentPath: bodyPath })).toBe(
          "var _temp;\nexport default (_temp = fn(), x, _temp);",
        );
      });

      it("edge case for babel-plugin-jest-hoist", function () {
        let varsHoistPoint;
        let i = 0;
        const logs = [[], []];
        traverse(parse(`{a;}`), {
          BlockStatement(path) {
            [varsHoistPoint] = path.unshiftContainer(
              "body",
              t.emptyStatement(),
            );
            path.traverse({
              Identifier(path) {
                if (i++ >= 5) {