continue
the challenge am having is explained below
Am trying to set a draft_id
value after the submit-recipients
data-testid is clicked.
The beforementioned value is passed to a React ContextProvider that wraps my component named SendSurvey
which in fact uses the draft_id
value
My 2 questions are
How do I import the
SendSurvey
component to the test spec written below?I have tried out doing this
import SendSurvey from '.../../src/website/Surveys/SendSurvey'
in my cypress test files but I get this import error
Just as a side note, I had imported thisimport { mount } from '@cypress/react'
but it caused mycy.visit
to failHow do I wrap my ContextProvider around the
SendSurvey
component (assuming we imported this component successfully) and pass in thedraft_id
value to its ContextProvider?Worth mentioning that I have imported React and createContext hooks from React successfully as such
import * as React from 'react' import { createContext } from 'react' /*lines skipped here*/ //what i want to do is to create a context provider and // pass in the value of the draft id to be used to get draft data const SendSurveyContext = createContext({}) const SendSurveyProvider = SendSurveyContext.Provider
The actual test spec
describe('Send Message To all contacts', () => {
beforeEach(() => {
cy.intercept('GET', `**/surveys/1`, {
fixture: 'surveys/survey_draft.json',
})
cy.intercept('GET', `**/surveys/1/survey_questions?**`, {
fixture: 'surveys/survey_questions_draft.json',
})
})
it.only('should successfully select all contacts from the api', () => {
cy.intercept('POST', '**/drafts', {
fixture: 'sendsurveys/contacts_draft_success.json',
}).as('createContactsDraft')
cy.intercept('GET', '**/contacts?**', {
fixture: 'sendsurveys/all_contacts.json',
}).as('fetchAllContacts')
cy.visit('/send-survey/1')
cy.get('[data-testid=all-contacts]').click()
cy.wait('@fetchAllContacts')
cy.get('[data-testid=submit-recipients]').click()
cy.contains('Successfully added the contacts.')
// this is where I would like to wrap my context provider around the `SendSurvey` component and
// pass in the draft_id value
})
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)