How to test this case?
I have a variable in the settings:
setup() { const address = `${process.env.VAR_ENV}` onMounted(async () => { const stop = await isContinuing(address)
When the test is running, the function await isContinuing(address)
is executing. How can I make the function not run while the test is running?
My test has undefined wrapper 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 ) })
P粉9174060092024-02-18 10:10:35
Jest (and I assume most testing frameworks) sets the NODE_ENV environment variable to test
. So you can use a simple if
statement to not do something in your test:
if(process.env.NODE_ENV !== 'test') { const stop = await isContinuing(address) }