var v = 42;
var o = { a: 1, b: [2,3,4] };
logger`This is my value: ${v} and another: ${o}`;
// This is my value: 42 and another: {"a":1,"b":[2,3,4]}
try {
const condition = true; | |
const App = () => ( | |
<div> | |
<h1>This is always visible</h1> | |
{ | |
condition && ( | |
<div> | |
<h2>Show me</h2> | |
<p>Description</p> |
const memoize = (fn) => { | |
let cache = {}, key; | |
return (...args) => { | |
key = JSON.stringify(args); | |
return cache[key] || (cache[key] = fn.call(null, ...args)); | |
} | |
}; |
var v = 42;
var o = { a: 1, b: [2,3,4] };
logger`This is my value: ${v} and another: ${o}`;
// This is my value: 42 and another: {"a":1,"b":[2,3,4]}
try {
// permutation: Permutação | |
// P(n) = n! | |
// Exemplo: número de anagramas da palavra LIVRO = P(5) = n! | |
// Possibilidades de uma fila de 25 pessoas = P(25) = 25! | |
// combination: Combinação | |
// C(p,n) = = n! / p!(n - p)! | |
// Exemplo: formar comissão de 3 pessoas escolhidas entre 10 pessoas. C(3,10) = 10! / 3!(10 - 3)! | |
// arrangement: Arranjo |
good doc! some quick answers -
It seems like act() is being recommended for wrapping all state updates in React tests, but is it necessary to use it everywhere if you can use waitForElement to turn the whole test async?
This is a very good question, and something I grappled with earlier. A couple of things that stood out for me -
waiting for an element is indeed pretty close to what a user's experience is like; ie - a user 'waits' for the form to show itself, after which they fill it in and click a button, then 'wait' for the success screen etc. Ultimately, act()
makes this test stronger - it'll ensure that effects, and queued promises, have been flushed before you interact with the element. wrapping waitForElement with act()
(the async version, ie), will make this invisible to the user, but with the guarantee that their UI is 'stable'.
I couldn't assume that all tests would use waitForElement
. For example, using timers is common for testing transitions and such. In these scenarios too, ac
const uid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { | |
const r = Math.random() * 16 | 0 | |
const v = c === 'x' ? r : r & 0x3 | 0x8 | |
return v.toString(16) | |
}) |
Este método evita conflitos durante eo merge, se você tem que periódicamente fazer pull da master em sua branch. Também da a oportuniadade de realizar squash em mais de um commit ou para re-organizar seu código completamente em diferentes commits (ex: se você terminou seu trabalho em três diferente features mas os commits não foram consecutivos).
*Nota: Você não pode usar esse método se você pretende abrir um Pull Request para realizer merge da sua branch. Esse método requer commits diretamente na master.
Troque para a branch master e certifique-se de estar tudo atualizado:
/** | |
* Given you have a JSON string that represents a single object (not array). | |
* SanitizeJsonString will attempt to correct the JSON syntax allowing | |
* it to be parsed. | |
*/ | |
/** | |
* Sanitize user input before attempting to parse the JSON | |
* |