Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!