Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
TypeError: Cannot read property 'fraction' of undefined - Cypress/Javascript

I am doing a test where I grab an odds value and store it as a fraction. Then I want to compare the value to a particular format depending on the option selected from the drop down.

I am trying to use these to set up the fraction and determine the odds format:

https://mathjs.org/docs/datatypes/fractions.html

How do I resolve that type error above.

Screenshot:

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If you want to use just fraction you can use:

const { fraction } = require("mathjs");

//In your test
fraction(oddsValue);

If you want to use others as well, you can do:

import { create, all } from "mathjs"
const math = create(all, {})

//In your test
math.fraction(oddsValue)
about 4 years ago · Juan Pablo Isaza Relatório

0

The mathjs has no default export, so you import everything (*) and then name it in your import

import * as math from 'mathjs'

This is the main entry point for the mathjs package.

// configuration
export { config } from './configReadonly.js'

// functions and constants
export * from './pureFunctionsAny.generated.js'
export * from './impureFunctionsAny.generated.js'
export * from './typeChecks.js'

// error classes
export { IndexError } from '../error/IndexError.js'
export { DimensionError } from '../error/DimensionError.js'
export { ArgumentsError } from '../error/ArgumentsError.js'

// dependency groups
export * from './dependenciesAny.generated.js'

// factory functions
export * from '../factoriesAny.js'

// core
export { create } from '../core/create.js'
export { factory } from '../utils/factory.js'

If it had a default export, there would be

export default {
  function1,
  function2,
  function3,
  ...
}

and then you can import it without using * as math.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda