मुझे इस मुद्दे के आसपास अपने सिर को लपेटने में बहुत मुश्किल समय है, इसलिए किसी भी मदद की सराहना की जाएगी।ककड़ी में jQuery अजाक्स डिबगिंग + कैपिबरा + रेल में पैंटॉमजेएस
मैं बस अपनी परियोजना पर एक साधारण अजाक्स-आधारित पंजीकरण फॉर्म का परीक्षण करना चाहता हूं। यदि फॉर्म सबमिशन सफल है, तो आपको स्वागत पृष्ठ पर रीडायरेक्ट किया जाता है। यदि ऐसा नहीं है, तो आपको प्रत्येक अपमानजनक फ़ील्ड से संबंधित उचित सत्यापन त्रुटियां मिलती हैं।
कुछ अजीब कारणों से, कैपिबरा रीडायरेक्ट का पालन नहीं कर रहा है। अजाक्स कॉल किया जा रहा है और मुझे डेटाबेस में पंजीकृत एक नया खाता दिखाई देता है, लेकिन onSuccess
कॉलबैक या तो कॉल नहीं किया जा रहा है, या रीडायरेक्ट को अनदेखा किया जा रहा है।
यहाँ (, मैं कोड घनीभूत हो गया संक्षिप्तता की खातिर) मैं क्या साथ काम करने के कोशिश कर रहा हूँ है:
फ़ीचर:
Feature: Registration
In order to obtain a new account
As a prospective customer
I must submit a valid registration form.
@javascript
Scenario: A valid registration attempt
Given an account registration form
When I complete the form with valid values
Then I should be redirected to the welcome screen
टेस्ट:
Given(/^an account registration form$/) do
visit("/signup")
assert current_path == "/signup"
end
When(/^I complete the form with valid values$/) do
within("#signupForm") do
fill_in("email", :with => Faker::Internet.email)
fill_in("name", :with => Faker::Name.name)
fill_in("password", :with => "11111111")
click_link("signupFormSubmit")
end
end
Then(/^I should be redirected to the welcome screen$/) do
assert current_path == "/welcome"
end
जावास्क्रिप्ट:
console.log('I am not yet inside you.')
$.post(url, form.serialize(), function(response) {
// everything went well
// let's redirect them to the given page
window.location.replace(response.redirectUrl)
console.log('I am inside you and it is good.')
}, function(response) {
// collect error responses from API
// apply error hints to associated fields
console.log('I am inside you and something went wrong.')
})
ठीक है, इसलिए यह विशेष परीक्षण ठीक तब तक चलता है जब तक हम उस बिंदु तक नहीं पहुंच जाते जहां हमें उपयोगकर्ता को स्वागत स्क्रीन पर रीडायरेक्ट करना होता है। मैंने onSuccess
, onFailure
कॉलबैक के अंदर क्या हो रहा है, यह देखने के लिए संभवतः मैं सबकुछ कोशिश कर सकता हूं, लेकिन इसका कोई फायदा नहीं हुआ। ऐसा लगता है कि कोड को भी निष्पादित नहीं किया जा रहा है।
Then I should be redirected to the welcome screen # features/step_definitions/registration.rb:51
Failed assertion, no message given. (MiniTest::Assertion)
./features/step_definitions/registration.rb:52:in `/^I should be redirected to the welcome screen$/'
features/registration.feature:15:in `Then I should be redirected to the welcome screen'
इससे कोई फर्क नहीं पड़ता अगर मैं एक अपवाद बढ़ा, यह उठाया नहीं प्राप्त करता है:
मैं सिर्फ परीक्षण रन से निम्नलिखित उत्पादन मिलता है। कॉलबैक के भीतर console.log()
पर कॉल न करें।
क्या किसी ने इसे देखा है? यदि हां, तो क्या कोई कामकाज है? अगर आपको अधिक जानकारी चाहिए, तो कृपया पूछें, मैं प्रदान करने के लिए खुश हूं।