Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Cypress and Jest versions and remove Node 8 support #543

Merged
merged 15 commits into from Aug 26, 2020
Merged
5 changes: 5 additions & 0 deletions .changeset/five-students-joke.md
@@ -0,0 +1,5 @@
---
"frontity": patch
---

Deprecate the `URL` import from `"frontity"` in favor of the `new URL` global that is now present in both the browser and Node 10+.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x]

steps:
- name: Checkout
Expand Down
27 changes: 25 additions & 2 deletions e2e/e2e.js
Expand Up @@ -36,6 +36,9 @@ prod = prod || false;
cypressCommand = cypressCommand || "open";
suite = suite || "all";

// Flag to know if we have started Docker.
let isDockerRunning = false;

// Validate CLI args.
validateArgs(target, { possibleValues: ["es5", "module", "both"] });
validateArgs(browser, { possibleValues: ["firefox", "chrome", "edge"] });
Expand All @@ -62,6 +65,9 @@ process.chdir(__dirname);
// (in the background via the -d flag).
await execa("docker-compose", ["up", "-d"], { stdio: "inherit" });

// Set the flag. We will needed it later to stop the containers.
isDockerRunning = true;

// Wait until WordPress is responsive.
await waitOn({
resources: ["http-get://localhost:8080"],
Expand All @@ -73,7 +79,7 @@ process.chdir(__dirname);
// instances for testing.
await execa(
"docker-compose",
["run", "wp", "/bin/bash", "-c", "chmod -R 777 /var/www/html"],
["run", "--rm", "wp", "/bin/bash", "-c", "chmod -R 777 /var/www/html"],
{ stdio: "inherit" }
);
}
Expand Down Expand Up @@ -149,12 +155,29 @@ process.chdir(__dirname);
});
}
}
// Exit the process once Cypress ends.

if (isDockerRunning) {
// Stop all the containers and remove all the volumes that they use (the
// `-v` option).
await execa("docker-compose", ["down", "-v"], {
stdio: "inherit",
});
}

// Exit the process to indicate that everything went fine.
process.exit(0);
}
} catch (err) {
console.error(err);

if (isDockerRunning) {
// Stop all the containers and remove all the volumes that they use (the
// `-v` option).
await execa("docker-compose", ["down", "-v"], {
stdio: "inherit",
});
}

// We need to return the exit code so that the GitHub action returns a fail.
process.exit(1);
}
Expand Down
6 changes: 6 additions & 0 deletions e2e/integration/wordpress-01/wp-basic-tests.spec.js
Expand Up @@ -29,4 +29,10 @@ describe("WordPress plugins", () => {
"Hello from WordPress plugin"
);
});

it("dummy test, otherwise the previous test doesn't run", () => {
// I'm not sure why, but if I remove this test, the previous one doesn't run
// and if it fails, Cypress does not complain. I guess it is a bug in
// Cypress.
});
});