I am a newcomer to Vue and Jest testing, and I keep encountering this error when running a specific test. While I understand that this is a common issue, I am struggling to pinpoint the exact cause of the problem.
Here is the error message:
Test suite failed to run
Jest worker encountered 4 child process exceptions, exceeding retry limit
at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:185:21)
Below is the failing test snippet:
test("signupAsUser logs results if email is provided", async () => {
const consoleSpy = jest.spyOn(console, "log");
const email = ref("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3a7b6a0a7a6a0b6a193a0b0bca6a7b2a3befdb0bcbe">[email protected]</a>");
const { signupAsUser } = useSignup(email);
await signupAsUser();
expect(consoleSpy).toHaveBeenCalledWith("USER:", mockSignup);
});
Additionally, here are the files being tested. The Vue file:
<!--
View for user signup operations.
-->
<template lang="pug">
.Signup
.Signup__focus
.Signup__title Sign Up
.Signup__form
.Signup__field
va-input.Signup__emailInput(
type="email",
name="email",
placeholder="Email",
v-model="email",
@keyup.enter="signupAsUser()"
)
template(v-slot:prependInner="")
va-icon(name="email")
.Login__buttonRow
va-button.Login__submitButton(@click="signupAsUser") Sign Up
</template>
<script lang="ts">
import { ref, defineComponent } from "vue";
import useSignup from "@/views/Signup/useSignup";
/**
* Assemble the Signup component
*
* @returns Data for the component to use.
* - email: of the user to sign up with
* - signupAsUser: function to call to carry out the login operation.
*/
function setup() {
const email = ref("");
const { signupAsUser } = useSignup(email);
return {
email,
signupAsUser,
};
}
export default defineComponent({
name: "Signup",
setup,
});
</script>
<style lang="scss">
//basic scss style taken from Login.vue until button and verification code is added
.Signup {
position: fixed;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&__focus {
width: 360px;
max-width: 95vw;
}
&__field {
padding-bottom: 0.5em;
}
&__title {
font-size: 1.2em;
padding-bottom: 0.5em;
text-align: center;
}
}
</style>
and the TypeScript file:
import { Ref } from "vue";
import { useApolloClient } from "@vue/apollo-composable";
import { ValidatedUser } from "@/models";
import { gql } from "graphql-tag";
import router from "@/router";
const query = gql`
query Signup($input: Signup) {
signup(input: $input) {
__typename
token
user {
emailAddress
id
}
}
}
`;
/**
* Retrieve apollo client and provide useSignup
* function to validate input and execute Signup process.
*
* @param emailAddress - reactively wrapped email address of the user signing up.
* @returns useSignup composition functionality.
*/
export default function useSignup(emailAddress: Ref<string>): {
signupAsUser: () => Promise<void>;
} {
const { resolveClient } = useApolloClient();
async function signupAsUser(): Promise<void> {
console.log("emailAddress " + emailAddress.value);
if (emailAddress.value.length < 5) {
console.log("here");
return;
} else {
const client = resolveClient();
const variables = {
input: { username: emailAddress.value },
};
console.log("here");
console.log("emailAddress: ", variables);
}
router.push({ path: "/signup/verify" });
}
return { signupAsUser };
}
Any guidance on where the timeout issue might be originating from or how to troubleshoot would be greatly appreciated.