tnkgs / atkadai Goto Github PK
View Code? Open in Web Editor NEWreactテスト
reactテスト
reduxで実装してみる。
お世話になっております、徳山です。
課題としては完了したのですが、原因が分からず仕舞いの問題が発生してしまいました。
testのcomponentを作成している際、Toast.spec.tsxに元々あるtest文'Should call onRequestClose callback on 3 seconds after the mount'はToast.tsx内の3秒間をsinon.useFakeTimers()で進めて、onRequestCloseの呼び出しの有無を確かめるという内容でしたが、改変後のToast.tsxではどうしても通すことが出来ませんでした。
改変前は通すことが出来ました。
結局はuseFakeTimersを使わずに、test側でsetTimeoutを使うことでpassすることが出来ましたが、原因が分かりませんでした。
onRequestCloseが実行されるまでの時間を測ってみましたが、問題はありませんでした。
恐らく、Node.Timerを使っていないことか、非同期であることが原因であると考えていますが、もしこの問題の原因に心当たりがありましたら、お教え頂けると嬉しいです。
お世話になっております徳山です。
課題について、再び問題が生じたので質問させて頂きたいです。
今回の質問は技術的な質問、gitについての質問、testについての質問が一つずつあります。
長くなってしまいましたが、今回も読んで貰えると幸いです。
まず技術的な問題について、index.tsxのhandleRemove(Toastを削除する)のToastの指定についての質問です。
ToastのhandleCloseを非同期にしたところ、index.tsx内のhandleRemoveに返ってくるindex, textはToast作成時のパラメタのままなので、二つ続けてToastを作成したり、CloseボタンでToastを消したりすると順番がズレて、indexが信用できなくなってしまいます。
どうしても解決策が思いつかなかったので、質問させて頂きました。簡単なヒントでも、出して頂けると助かります。
添付されているatkadai_src.zip内のsrc/index.tsxの冒頭のコメントアウトに、試したことが書かれてあります。
atkadai_src.zip
次にgitについて、ヒントに従ってブランチ:questionを分けてpushしたのですが、上手くいきません。
エラーは以下のようになってしまいます。
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin question:question
remote: Permission to mtsug1/atkadai.git denied to tkymwtr.
fatal: unable to access 'https://[email protected]/mtsug1/atkadai.git/': The requested URL returned error: 403
Pushing to https://[email protected]/mtsug1/atkadai.git
これに関してインターネットにヒントが沢山あったのですが、ある程度試しても上手くいかなかったので、質問させて頂きました。sshではkeyを作りましたが、認証に失敗してしまいます。
元々bitbucketを利用していまして、gitとの接続先としてgitのアカウントを作ったのですが、もしかすると原因に関係しているかもしれません。
もし原因にお心当たりがありましたら、お教えください。
最後に、testについての質問です。testについてコードカバレッジを測るとのことなのですが、chaiを用いた方が良いでしょうか?
以上です。二度目の質問で恐縮なのですが、よろしくお願い致します。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.