- Create your realm / client
- Inside client configuration go to "Mappers"
- Click on "Create"
- Name it "hasura"
- Choose Mapper Type "Script Mapper"
- Add following script to demonstrate how it works
const pombify = (phrase) => { | |
return phrase | |
.split(' ') | |
.map((word) => { | |
const wordLetters = word.split('') | |
return wordLetters | |
.map((letter, index) => { | |
const charCode = letter.charCodeAt(0); | |
const binary = charCode | |
.toString(2) |
/* Ultra lightweight Github REST Client */ | |
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const token = 'github-token-here' | |
const githubClient = generateAPI('https://api.github.com', { | |
headers: { | |
'User-Agent': 'xyz', | |
'Authorization': `bearer ${token}` | |
} | |
}) |
/* Using a JavaScript proxy for a super low code REST client */ | |
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
// also see https://github.com/fastify/manifetch | |
// also see https://github.com/flash-oss/allserver | |
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const createApi = (url) => { | |
return new Proxy({}, { | |
get(target, key) { |
/** | |
* Convert string booleans to boolean | |
* @param {Array, Object, String} date | |
* @returns {Array, Object, String, Boolean} | |
*/ | |
const convertStringBoolean = (data) => { | |
if (Array.isArray(data)) return data.map(d => convertStringBoolean(d)) | |
if (typeof data === 'object') { | |
for (const key in data) { | |
data[key] = convertStringBoolean(data[key]) |
const delayPromiseToTest = (timeout = 1000, error = null) => new Promise((resolve, reject) => { setTimeout(() => error instanceof Error ? reject(error) :resolve(), timeout) }) |
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 withact()
(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
For excessively paranoid client authentication.
Organization & Common Name: Some human identifier for this server CA.
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
function logger(strings,...values) { | |
var str = ""; | |
for (let i = 0; i < strings.length; i++) { | |
if (i > 0) { | |
if (values[i-1] && typeof values[i-1] == "object") { | |
if (values[i-1] instanceof Error) { | |
if (values[i-1].stack) { | |
str += values[i-1].stack; | |
continue; | |
} |
None of the string methods modify this
– they always return fresh strings.
-
charAt(pos: number): string
ES1Returns the character at index
pos
, as a string (JavaScript does not have a datatype for characters).str[i]
is equivalent tostr.charAt(i)
and more concise (caveat: may not work on old engines).