mint-metrics / mojito-js-delivery

🧪 Source-controlled JS split testing framework for building and launching A/B tests.
https://mojito.mx/docs/js-delivery-intro
Other
16 stars 30 forks source link

Mojito JS packages updates #101

Closed allmywant closed 2 years ago

allmywant commented 2 years ago

Replaced the mocha-phantomjs with puppeteer-core; Updated package-lock.json to remove vulnerabilities; Updated nodejs.yml to replace npm install with npm ci;

kingo55 commented 2 years ago

I have it working here - it feels like tests are running a little quicker!

I did however run into a couple of glitches when testing in our Mojito repo.

Update Bitbucket Pipelines YAML

Seems like we need to use npm ci and update the Pipeline's default image to e.g. image: node:12:

image: node:12

pipelines:
  custom:
    nuke:
      - step:

...

    development:
      - step:
          name: Build & publish to staging
          deployment: staging
          caches:
            - node
          script:
            - "npm ci"
            - npm install -g gulp-cli
            - gulp build
            - gulp publish --awsk $AWS_ACCESS_KEY_ID --awss $AWS_SECRET_ACCESS_KEY

Is node v12 fine to use? Would it be better to use a later image?

Issue when running tests locally

With a clean Mojito repo, tests run fine, however when I run them in git@bitbucket.org:mintmetrics/mojito-pipeline.git it's failing with:

$ gulp test
[22:30:40] Using gulpfile ~/Documents/mojito-pipeline/gulpfile.js
[22:30:40] Starting 'test'...
[22:31:11] 'test' errored after 31 s
[22:31:11] TimeoutError: waiting for function failed: timeout 30000ms exceeded
    at new WaitTask (/Users/robertkingston/Documents/mojito-pipeline/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.js:526:34)
    at DOMWorld.waitForFunction (/Users/robertkingston/Documents/mojito-pipeline/node_modules/puppeteer-core/lib/cjs/puppeteer/common/DOMWorld.js:477:26)
    at Frame.waitForFunction (/Users/robertkingston/Documents/mojito-pipeline/node_modules/puppeteer-core/lib/cjs/puppeteer/common/FrameManager.js:993:32)
    at Page.waitForFunction (/Users/robertkingston/Documents/mojito-pipeline/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.js:2479:33)
    at module.exports (/Users/robertkingston/Documents/mojito-pipeline/scripts/run-tests.js:37:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I don't know what's causing it because it works fine when I run the tests from an empty container.

allmywant commented 2 years ago

@kingo55

Is node v12 fine to use? Would it be better to use a later image?

Yes, node V12 is fine but v14 and v16 is better.

I don't know what's causing it because it works fine when I run the tests from an empty container.

I cloned the mojito-pipeline repo and reproduced the issue on my end. The reason is the test_suite.html requires <script src="../dist/assets/js/mojito.js"></script> For the mojito-pipeline repo, it should be <script src="../dist/assets/js/mintmetrics.js"></script>

kingo55 commented 2 years ago

@allmywant - thanks.

Can you please update the node versions we use/test against in Github Actions and Bitbucket Pipelines please? I trust your judgement on what we should test against. Might as well bump these in the same commit since we're removing an old version.

Also, please change the npm install references over to npm ci in the Bitbucket Pipelines. Will get it merged in then.

allmywant commented 2 years ago

@kingo55 I've updated node version to [12.x, 14.x, 16.x] for Github Action and upgrade docker image to atlassian/default-image:3 for Bitbucket pipelins.

https://hub.docker.com/r/atlassian/default-image