Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add unit tests for noiseDetail()

Open Beginner friendly
#9,253 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@Pcmhacker-piro is already working on this.

Since Oct 6, 2026.

  • #9255 by @Pcmhacker-piro — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Read src/math/noise.js around noiseDetail() and the existing tests in test/unit/math/noise.js. Add tests for setting octaves and falloff, invalid values, and omitted falloff; restore the default state afterward so other tests are unaffected. Run the noise unit tests and update the outdated comment; done when the requested behaviors are covered and the suite passes.

Written by the indexing model from the issue text.

Description

Area:Math Enhancement
Increasing access

Tests make noiseDetail()'s behaviour explicit and protect it from regressions, so sketches that rely on it keep working across releases. They also give new contributors a clear reference for how the function is meant to behave.

Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
Feature enhancement details

noiseDetail() (src/math/noise.js:403-410) has no unit tests. test/unit/math/noise.js:19 notes this:

// ALso need test for noiseSeed and noiseDetail

noiseSeed has since been covered (lines 36-60), but noiseDetail hasn't.

The private getters _getNoiseOctaves() and _getNoiseAmpFalloff() (lines 416-425) make the state directly assertable. Proposed tests:

  • sets octaves and falloff when both are given
  • ignores lod <= 0 and falloff <= 0, keeping the previous values
  • when falloff is omitted it defaults to 0.5, so a previously set falloff is reset rather than kept

Since the suite shares one mockP5Prototype and noiseDetail state persists in the module closure, the new tests would restore the defaults (4 octaves, 0.5 falloff) afterwards so the existing noise() tests aren't affected.

I'd also update the comment at line 19, since noiseSeed is now tested.

Checked against main at 3193703. The strands noiseDetail tests in the WebGL/WebGPU shader suites cover state leaking between shaders, not this function.

I'd like to fix this myself if approved.

Dominant language
JavaScript
Stars
24.1k
Forks
3.9k
Avg merge
3d 19h
Merged PRs (30d)
33

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from processing/p5.js

All issues in processing/p5.js

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.