gpt4 book ai didi

javascript - PhantomJS:无法在描述中进行设置/拆卸

转载 作者:行者123 更新时间:2023-11-28 06:35:47 28 4
gpt4 key购买 nike

有人以前见过这个并且知道它的含义吗?

14:13:43 PhantomJS 1.9.8 (Linux) ERROR
14:13:43 Error: Cannot have setup/teardown in describe for: athena-vertical-expanding-carousel
14:13:43 at /home/jenkins/workspace/Shared_GD_Build/frontend/test/js/test.js:40

我有一组非常相似的测试,它们正在工作,但可能有问题:

define([
"jquery",
"underscore",
"common/athena/vertical-expanding-carousel"
], function ($, _, AthVertExpandingCarousel) {

describe("common/", function () {
describe("athena/", function () {

describe("athena-vertical-expanding-carousel", function () {
var $fixture,
carousel,
sandbox;

beforeEach(function () {
sandbox = sinon.sandbox.create();
$fixture = $([
"<div id='vert-carousel-test-outer' class='generic_container'>",
"<div id='vert-carousel-test' class='js-vertCarouselMainContainer" +
" vertCarouselMainContainer carousel'>",
" <ol class='js-carousel-items'>",
" <li class='selected'>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" <li>",
" <div><a href='#'><img data-lazy='/static-mock/empty.png' /></a></div>",
" </li>",
" </ol>",
"</div>",
"<div class='paginator-container' id='paginator-container'>",
" <div class='js-up-down-controls'>",
" <div class='js-up-controls'>",
" </div>",
" <div class='js-down-controls'>",
" </div>",
" </div>",
"</div>",
"</div>"
].join("\n")).appendTo($("#fixtures-visible"));
});

afterEach(function () {
$fixture.remove();
sandbox.restore();
if (carousel) {
carousel.remove();
}
});

describe("base case", function () {

it("should not have any new classes indicating initialization if a bad " +
"selector is sent", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($("nada"),
{maxRows: 5});

expect($upDownControls).to
.not
.have.$class("atTop").and
.have.$class("atBottom");
});

it("should have class of atTop and not atBottom in controlls after " +
"being initialized", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});

expect($upDownControls)
.to.have.$class("atTop").and
.to.not.have.$class("atBottom");
});

// We may add an init option to start with more than one row,
// but for now we start at 1 row
it("should have class of vertPages1 after being initialized", function () {
var $vertCarouselContainer = $("#vert-carousel-test");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});

expect($vertCarouselContainer)
.to.have.$class("vertPages1");
});

it("should have class of vertPages2 and lose the the atTop class " +
"in controls after init and a downclick", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");
$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});
$upDownControls.find(".js-down-controls").click();

expect($vertCarouselContainer)
.to.have.$class("vertPages2").and
.to.not.have.$class("atTop");
});

it("should have class of atTop and not the atBottom class " +
"after init and an upCLick", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});
$upDownControls.find(".js-up-controls").click();

expect($upDownControls)
.to.have.$class("atTop").and
.to.not.have.$class("atBottom");
});

it("should have class of vertPages1 and data value of 1 for vertCarSize " +
"after init and an upCLick", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});
$upDownControls.find(".js-up-controls").click();

expect($vertCarouselContainer)
.to.have.$class("vertPages1");
});

it("should have class of vertPages3 and data value of 3 for vertCarSize " +
"after init and TWO downClicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});
$upDownControls.find(".js-down-controls").click().click();

expect($vertCarouselContainer)
.to.have.$class("vertPages3");
});

it("should have class of atTop and not atBottom after being initialized, " +
"a downclick and an upclick", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 5});
$upDownControls.find(".js-down-controls").click();
$upDownControls.find(".js-up-controls").click();

expect($upDownControls)
.to.have.$class("atTop").and
.to.not.have.$class("atBottom");
});

it("should have class of atBottom and not atTop after being initialized w " +
"max of 3 rows and two downclicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 3});
$upDownControls.find(".js-down-controls").click().click();

expect($upDownControls)
.to.have.$class("atBottom").and
.to.not.have.$class("atTop");
});

it("should have class of atBottom and not atTop after being initialized w max " +
"of 3 rows and three downclicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer,
{maxRows: 3});
$upDownControls.find(".js-down-controls").click().click();

$upDownControls.find(".js-down-controls").click(); // one too many
expect($upDownControls)
.to.have.$class("atBottom").and
.to.not.have.$class("atTop");
});

it("should have class of atBottom and not atTop after being initialized w NO MAX " +
"rows and three downclicks but not at two downclicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer, {});
$upDownControls.find(".js-down-controls").click().click();

expect($upDownControls)
.to.not.have.$class("atBottom").and
.to.have.$class("atTop");

$upDownControls.find(".js-down-controls").click();
expect($upDownControls)
.to.have.$class("atBottom").and
.to.not.have.$class("atTop");
});

it("should have data value of vertCarSize=4 after being initialized w NO MAX " +
"rows and three downclicks but only 3 after two down clicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer, {});
$upDownControls.find(".js-down-controls").click().click();

expect($vertCarouselContainer).to.have.$class("vertPages3");

$upDownControls.find(".js-down-controls").click();
expect($vertCarouselContainer)
.to.have.$class("vertPages4");
});

it("should have data value of vertCarSize=4 after being initialized w NO SECOND PARAM " +
"rows and 3 downclicks but only three after 2 down clicks", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer);
$upDownControls.find(".js-down-controls").click().click();

expect($vertCarouselContainer).to.have.$class("vertPages3");

$upDownControls.find(".js-down-controls").click();
expect($vertCarouselContainer)
.to.have.$class("vertPages4");
});

it("should have startTransition and then transitionComplete as a class after leaving " +
"atTop", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

sandbox.useFakeTimers();

$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer, {});

$upDownControls.find(".js-down-controls").click();

expect($upDownControls).to.have.$class("startTransition");
expect($upDownControls).to.not.have.$class("transitionComplete");
expect($upDownControls).to.not.have.$class("atTop");

sandbox.clock.tick(1750);

expect($upDownControls).to.have.$class("transitionComplete");
expect($upDownControls).to.not.have.$class("startTransition");

});

it("should have startTransition and then transitionComplete as a class after leaving " +
"atBottom", function () {
var $vertCarouselContainer = $("#vert-carousel-test"),
$upDownControls = $vertCarouselContainer.parent().find(".js-up-down-controls");

sandbox.useFakeTimers();
$vertCarouselContainer.addClass("js-vertical-carousel-main-container");

carousel = AthVertExpandingCarousel.init($vertCarouselContainer, {maxRows: 2});

$upDownControls.find(".js-down-controls").click().click();
sandbox.clock.tick(1750);

$upDownControls.find(".js-up-controls").click();

expect($upDownControls).to.have.$class("startTransition");
expect($upDownControls).to.not.have.$class("transitionComplete");
expect($upDownControls).to.not.have.$class("atBottom");

sandbox.clock.tick(1750);

expect($upDownControls).to.have.$class("transitionComplete");
expect($upDownControls).to.not.have.$class("startTransition");

});
});
});
});
});
});

最佳答案

一位同事帮助我意识到我在两个不同的 .spec 文件中使用了相同的“描述”字符串:

describe("athena-vertical-expanding-carousel", function () {

我不知道 phantom、jenkins 等可以配置得如此严格以防止重复标签,但这是有道理的。

我无法找到针对此确切错误的 stackoverflow 问题,因此我希望这会对某些人有所帮助......

关于javascript - PhantomJS:无法在描述中进行设置/拆卸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34300707/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com