Below are my functions. I need these in my React/Gatsby app therfor I export it with ESM export syntax. but i cannot use it for testing.
problem to: see printscreen.. Jest doesn't seem to like the Json file?enter image description here
import gameOfThrones from "../data/gameOfThrones.json";
const getGameOfThronesData = ()=> {
console.log(gameOfThrones.gameOfThrones.episodes)
}
const getEpisodesPerSeason = (season)=> gameOfThrones.gameOfThrones.episodes.filter(episode=> episode.season === season)
const getEpisodeData = (episodeId)=> gameOfThrones.gameOfThrones.episodes.find(episode=> episode.id === episodeId)
const getNextEpisode = episodeId => null
const getPrevEpisode = episodeId => null
export {getGameOfThronesData, getEpisodesPerSeason, getEpisodeData, getNextEpisode, getPrevEpisode}
// module.exports = {
// getGameOfThronesData, getEpisodesPerSeason, getEpisodeData, getNextEpisode, getPrevEpisode
// };
Aucun commentaire:
Enregistrer un commentaire