Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
How can I stop the function execution in my test?

How can I test this case?

I have a variable in the setup:

setup() {
      const address = `${process.env.VAR_ENV}`
  onMounted(async () => {
        const stop = await isContinuing(address)

The function await isContinuing(address) is executing when the test is run. How can I make the function not run when the test is ran?

My test's undefined wrap variable

beforeEach(() => {
  wrapper = shallowMount(App, {
  })
})

describe('Dashboard', () => {
  it('test to verify if initial section.', () => {
    const expected = 0
    expect(wrapper.findComponent({ ref: 'section' }).element.value).toBe(
      expected
    )
  })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Jest (and I assume most test frameworks) sets NODE_ENV enviromental variable to test. So you can use a simple if statement to not execute something in tests:

if(process.env.NODE_ENV !== 'test') {
  const stop = await isContinuing(address)
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!